News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

WebView2 test

Started by TimoVJL, November 26, 2023, 09:51:24 PM

Previous topic - Next topic

TimoVJL

@jorgon
Good, if i was helpful for you.
I check a your code, if i can learn something new in old age.
May the source be with you

Vortex

Hş Jeremy,

Nice work :thumbsup:

NoCforMe

#17
Quote from: jorgon on May 23, 2024, 02:33:48 PMMany thanks TimoVJL for the files showing how you implemented WebView2 in C, and in particular the header files and the exe.
Jeremy, I've only taken a cursory look at your code, but I have to say something here: I don't know if it was your intent or not, but I have to commend you for opening the door and shining daylight on what is normally clear as mud to us assembly programmers, namely the dense forest of a C++ program with its hidden features and other obscure elements.

I'm interested in this, as I am an assembly-only (MASM) programmer at this point and would like to be able to borrow from C++ examples in my own code. This has seemed like a near-impossible task until now. (I've done some GDI+ programming, which is normally only accessible through C++, but I've used the "flat" libraries which allow access through regular Win32 function calls.)

Especially interesting to me are those "methods" you uncovered in this web application, which are really just pointers to functions (yes, regular old callable Win32 functions) in a list of "methods". I think of what you've done here as something like that scene in the Wizard of Oz where the curtain is pulled back to reveal that it's merely a little man behind all the magic.

One thing: can you tell us where you get the C++ header files to extract that info? I'd like to take a look at them myself. Maybe you could post some of them here.
Assembly language programming should be fun. That's why I do it.

jorgon

Hi NoCforMe

Many thanks for your comments and yes I did want to remove the mystery as far as I could. I was not being altruistic - it was for my own purposes, because I'm writing an Email Client in GoAsm to replace Everdesk which is no longer being supported and which keeps freezing on my machine.  Currently, the Email Client I am writing uses WebBrowser2 to display and edit html emails, but that has limited functionality (it can't render base64 images in the email for example).  So I was looking for an alternative.  WebView2 has many more features, but when running it creates a whole load of files and folders (user data files) and I haven't found a way to stop it doing this yet.  When all you want to do is to display or edit an html email you really don't need a history audit!

The trouble is, it always takes me a while to decipher the C++ and C# stuff.  There are others who can read it much better than me, hence TimoVJL's pure C and the exe he provided (which I could disassemble and compare with the C) was the breakthrough I needed. 

As for the header files, I believe for WebView2 there is only one - WebView2.h. One problem is that there are different versions of this file.  The one TimoVJL posted shows the various structures showing the offsets of the "methods" most clearly.  It is 987K and I attach this as a zip file.  The other versions I have seen are 239K and the one which shipped with the WebView2 Runtime which I download from Microsoft was 512K, but they are not so useful. 

Now all these files have the same name which seems to me to be a recipe for disaster if you are constrained by one of the platform development tools and you have the wrong file - no wonder development teams spend half the time configuring the development tools instead of actual programming like assembler programmers can!

TimoVJL

I just created header file from WebView2.tlb, as it can be found from NuGet package.

There might be several WebView2.h files around, that are generated in same way.

MS header file is 1836 KB, so not ideal for other programming languages.
May the source be with you

jorgon

CommWebView2 builds on HelloWebView2.asm to show how it is possible to establish two way communication with the WebView2 browser, and use it as a rich text (html) editor.  It explains the use of Navigate, NavigateToString, ExecuteScript, execCommand, and add_WebMessageReceived.
Sorry it's in GoAsm but could be converted to other languages.

morgot

jorgon, thanks for the code.
But why do I need to install some components to make webview2 work? If I already have microsoft edge in Windows. Why doesn't it take webview2 from there, but I need to install something else? How does it work?
Sorry for the bad English

TimoVJL

WebView2 will be part of windows 10 and 11, so only older versions needs that runtime dll.
I haven't found, when it will be an update to Windows 10.

Delivering the Microsoft Edge WebView2 Runtime to Windows 10 Consumers
May the source be with you

morgot

Quote from: TimoVJL on August 06, 2024, 09:34:37 PMso only older versions needs that runtime dll
OK, but why I can't only copy runtime.dll? Why I need to install all SDK?
Sorry for the bad English

zedd151

Quote from: morgot on August 06, 2024, 11:41:40 PMOK, but why I can't only copy runtime.dll? Why I need to install all SDK?
I would venture to guess that there may be some dependencies which would be missing in that scenario. The .dll might depend on other parts of the SDK. But that is only a guess.
Windows 10 'convert'.   :skrewy:

TimoVJL

SDK is for developers, and who share that dll with their application.
No installations, just one dll in same folder as application, if edge was installed earlier.
Stay tuned  :smiley:

Implementation of WebView2
May the source be with you