Re: CInternetSession in DLL - afxinet.h vs windows.h problems
"Bob" <jeep@rahul.net> wrote in message
news:2b82669b-c497-45ab-ae83-677ec3f8ffd3@g39g2000pri.googlegroups.com...
I was given some source code which has 2 projects in it.
One is a DLL which the other uses, specifically the DLL does some
keyboard/mouse interceptions for keylogging etc.
My problem is that Im trying to use CInternetSession in the DLL, so I
added
It sounds like your DLL is a hook DLL (installed with SetWindowsHookEx) and
that is put into every running process. If so, it is good practice to not
perform internet connectivity in the DLL, as the Internet will be accessed
by the process which caused your DLL to do that. For example, if your DLL
is injected into explorer.exe, and it tries to connect to the Internet, it
will look like explorer.exe is trying to communicate over the Internet. The
user could have configured his firewall not to allow that process to
communicate over the Internet. This breaks your code.
Anyway, that is just one example. Hook DLL's are best when kept very small
and simple. They typically post a Windows message to a host .exe to perform
things like Internet connectivity, on behalf of the DLL. So when your DLL
intercepts a keystroke or mouse movement that you want to report over the
Internet, the DLL would post a custom Windows message back to your host .exe
(the one that called SetWindowsHookEx to install your hook DLL in the first
place), which would then do the CInternetSession stuff.
BTW, it is well noted that the MFC Internet wrappers like CInternetSession
aren't that great, and it is recommended to use WinInet directly. Also,
WinInet itself is very old has been deprecated with WinHttp. (But I've not
used WinHttp.)
-- David