Just wrote a little program (2.5KB) that at a predetermined time every 24 hours, connects to the internet, opens a predetermined URL in Internet Explorer, disconnects and then closes Internet Explorer. Now the program works just fine, but I would like to know if the methods I have employed in this program are sound.

1. My message loop goes like this:
;	----- Message loop

@@: xor eax, eax
invoke GetMessage, ADDR msg,eax,eax,eax
test eax, eax
jz @F
invoke DispatchMessage, ADDR msg
@@: invoke ExitProcess, eax

2. My window (the actual window is not used) is registered & created like this:

style DWORD 0
lpfnWndProc DWORD OFFSET WndProc
cbClsExtra DWORD 0
cbWndExtra DWORD 0
hInstance DWORD 400000h
hIcon DWORD 0
hCursor DWORD 0
hbrBackground DWORD 0
lpszMenuName DWORD 0
lpszClassName DWORD OFFSET ClassName


invoke RegisterClass, addr wc
xor ecx, ecx
INVOKE CreateWindowEx,ecx,ADDR ClassName,ADDR AppName,\
ecx,ecx,ecx,ecx,ecx,ecx,ecx, 400000h,ecx

3. The documentation for InternetAutodial says it wants the handle of the parent window. Why?
I call it like this (ebx is zero, by the way):

4. After using CreateProcess to open Internet Explorer, I use the following code to close it (must be a simpler way):
xor ebx, ebx

invoke FindWindow, addr IEClName, ebx
push eax
invoke SendMessage, eax, WM_DESTROY, ebx, ebx
pop eax
invoke SendMessage, eax, WM_NCDESTROY, ebx, ebx
invoke CloseHandle, pinfo.hThread
invoke CloseHandle, pinfo.hProcess
Posted on 2003-04-25 20:29:48 by GreenScreenAlternator

When you create the window that is required, you should have a working Wndproc with it as well that you set the address for in the WNDCLASS / EX structure.

Once you have performed the code you want , all you need to do is a

invoke Sendmessage,hWnd,WM_SYSCOMMAND,SC_CLOSE,0

Just make sure that your WndProc has the normal shutdown code in it.

.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0

This should work fine for you.


Posted on 2003-04-25 22:59:17 by hutch--

Thanks for the feedback.

Yes, I have a working WndProc. This sets up the 24 hour timer, processes the message sent when a user clicks on exit in my tray icon and as you say, processes the WM_DESTROY message.

I'm a little confused over when I would use your code:

invoke Sendmessage,hWnd,WM_SYSCOMMAND,SC_CLOSE,0

This will surely close my program? I don't want that. It needs to connect to the internet every 24 hours.
Posted on 2003-04-26 03:30:19 by GreenScreenAlternator

xor ebx, ebx
invoke FindWindow, addr IEClName, ebx
[B]invoke Sendmessage,eax,WM_SYSCOMMAND,SC_CLOSE,0[/B]

Should do it. You mistook his point.

Posted on 2003-04-26 03:34:13 by Fake51

I'm so stupid!

That code works great. Now I'm 34 bytes leaner!
Posted on 2003-04-26 03:54:28 by GreenScreenAlternator