-
Web browser Control
'Lo -
I'm new to the forum - been reading it for some time. However, I finally have a question that I haven't been able to solve elsewhere:
Now that I have delved into the Win32 API, I would like to find some resources on how to connect to a web server through my win32 C app. Basically I want to be able to connect to my website(s), access a PHP script that displays an image, and display that image in the application.
Any help/resources/tutorials on the subject would be greatly appreciated.
Ay thank you
- rednax
-
There is a few ways to do this. If you just want to display a web page in a dialog, try this:
Code:
#include <windows.h>
#include <Urlmon.h>
#include <mshtmhst.h>
int main() {
SHOWHTMLDIALOGFN* pfnShowHTMLDialog;
HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL"));
if (hinstMSHTML == NULL)
{
// Error loading module -- fail as securely as possible
return 0;
}
pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*)GetProcAddress(hinstMSHTML,
TEXT("ShowHTMLDialog"));
if (pfnShowHTMLDialog)
{
IMoniker *pURLMoniker;
BSTR bstrURL = SysAllocString(L"http://www.cboard.cprogramming.com");
CreateURLMoniker(NULL, bstrURL, &pURLMoniker);
if (pURLMoniker)
{
(*pfnShowHTMLDialog)(NULL, pURLMoniker, NULL, NULL, NULL);
pURLMoniker->lpVtbl->Release(pURLMoniker);
}
SysFreeString(bstrURL);
}
FreeLibrary(hinstMSHTML);
return 0;
}
Alternatively, for simplicity you can use UrlDownloadToFile or OleLoadPicturePath.
-
I don't have that mshtmhst.h header file. How can I do it then?
-
Remove the #include <mshtmhst.h> line and add this line instead.
Code:
typedef HRESULT STDAPICALLTYPE SHOWHTMLDIALOGFN (HWND hwndParent, IMoniker *pmk, VARIANT *pvarArgIn, WCHAR* pchOptions, VARIANT *pvArgOut);
-
But I still get one error:
Code:
25 C:\Programs\Dev-Cpp\Templates\webcontrol.cpp 'struct IMoniker' has no member named 'lpVtbl'
-
Either compile the code as C rather than C++ or change the line:
Code:
pURLMoniker->lpVtbl->Release(pURLMoniker);
to:
pURLMoniker->Release();
-
What library I should include?
Code:
[Linker error] undefined reference to `SysAllocString@4'
[Linker error] undefined reference to `CreateURLMoniker@12'
[Linker error] undefined reference to `SysFreeString@4'
-
I tested some libraries and I got rid of the sysallocstring and sysfreestring errors with liboleaut32.a library, but I still get the CreateURLMoniker@12 error.
Where can I get urlmon.lib library? I don't have it...
-
Basically Dev-C++'s uses lib as prefix for the libraries.. if not... try those free ones
-
I know it uses lib prefix, but I didn't find any library that contains urlmon in the filename...
And what free ones are you talking about?
-
Why the hell is a thread from 2003 being revived?
maxorator read the freakin rules before posting again. I'm getting tired of this