Hi all,

first of all .. I've done (read AND practiced) ALL tutorials on this site, and they were REALLY helpful!

I hope there will be a tutorial in the future that goes more in-depth into .dll files like sharing data between apps using the same .dll file.

I'll try to explain my problem:

I have a main application which loads the .dll file (offcourse). I have a small function 'GetWindowCaption' in the .dll file which I call from the main program that needs to return the caption of the focussed window back to the main program.

I've put this in my .dll file:
	GetWindowCaption	proc	sCaption: LPSTR


invoke GetFocus
invoke GetWindowText, current_app_handle, sCaption, 255
ret

GetWindowCaption endp


This function can be called from the main program like this (true?):


invoke GetWindowCaption, addr sAppCaption


This is supposed to fill the buffer 'sAppCaption' with the caption of the focussed window. Well, you guessed it, it doesn't :) Not even the caption of the main program. So I think it has something to do with the 'sharing' between the .exe and the .dll file?
I've tried calling the function directly from within the .dll file, but the caption remains empty. The 'current_app_handle' IS filled with the handle of the focussed window, so that isn't the problem I think.

I'm struggling with this for a couple of days now, but I can't seem to figure it out :(

Can someone please lighten me up here? :)

Thanx in advance.
dev0wn
Posted on 2005-01-06 14:50:24 by dev0wn
You are using the window handle and not the application instance handle right? Your approach should work fine, a dll function can fill memory declared in an exe. Where is your handle variable defined? in the dll or exe?

EDIT
by defined I meant inisialized
your handle variable should not be in a shared section of memory so each instance of the dll has its own copy.
Posted on 2005-01-06 15:20:38 by QuantumMatrix1024
Thanx for your reply!

My application handle is defined in the .dll file. But the application caption is defined in the .exe file.

I have this in my .dll file to obtain the application handle:


invoke GetModuleHandle, NULL
mov current_app_handle, eax


Also, after I call 'GetWindowText', eax returns 0. And after calling GetLastError, eax returns 1400. How do I know what error this is?

dev0wn
Posted on 2005-01-06 15:38:38 by dev0wn
Thanx for your reply!


invoke GetModuleHandle, NULL
mov current_app_handle, eax



This is your problem. This function return the module handle or instance handle not a window handle. GetWindowText expects a window handle as returned by CreatteWindow/CreateWindowEx, FindWindow, etc

As for error codes either look them up in MSDN or use FormatMessage
Posted on 2005-01-06 15:52:51 by QuantumMatrix1024