Win32API: FindWindow

S

Steve Tuckner

------=_NextPart_000_0086_01C3BB12.29AEE8C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

We are having trouble running a Win32 function to find if a window class
is currently registered (so we can see if our app is already running).
We use the Win32 function FindWindow to check for the existence of the
window class. When we do it in Ruby with Win32API, it doesn't work but
if we write a simple C app it does work. Below are the code fragments.
Any ideas?

Here's the C code that works for detecting the existence of the client's
window handle given its window class and name:

if ((hwnd = FindWindow("simplewin00041943040000::faxfinderclass",
"FaxFinder Fax Client Software")) != 0)
strcpy(szResult, "FaxFinder Application Found");
else
strcpy(szResult, "FaxFinder Application Not Found");
DrawText(hdc, szResult, strlen(szResult), &rt, DT_CENTER);

Here's the Ruby code fragments to try and achieve the same thing

$FindWindow = Win32API.new("user32","FindWindow",["p","p"], "L")
if (hwnd = $FindWindow.call("simplewin00041943040000::faxfinderclass",
"FaxFinder Fax Client Software")) != 0 then
mainDisplay.messageBox("FaxFinder Client Software already running
(look in system tray)", "ERROR")
return
end

In the above case, some non-zero window handle is always received,
whether the app is running or not.

Steve Tuckner



------=_NextPart_000_0086_01C3BB12.29AEE8C0--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top