Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: PowerBuilder
Expertise: Beginner
Feb 2, 1998

External function for checking a process

Question:
Our Powerbuilder application launches an external program using the RUN command. We use the Timer Event to keep checking if the process is running by using the KERNAL32 external function GetModuleHandleA.

However, this function is always returning ZERO, thus our PB app thinks the program just launched is NOT running. Can I use GetModuleHandleA for a 32-bit app on NT? Am I doing something wrong? What other way is there for PowerBuilder to see if another process is still running?

Answer:
Under 32-bit Windows, you cannot get a module handle for another process so the method you are using will not work.

A different solution that may solve your problem is to use the FindWindowA function, you can use the same Run command you have now and a similar loop but instead of looking for the Module Handle you can look for the window title.

When you run your process note down the title bar of the window that gets created, then use the FindWindowA function to look for the window, when you can no longer find the window your process will be complete.

The definition for FindWindowA is as follows:

HWND FindWindow( 
LPCTSTR lpClassName, // pointer to class name 
LPCTSTR lpWindowName // pointer to window name 
); 

If the HWND returned is zero then the window was not found. HWND is a long, LPCTSTR is a string passed by reference. Remember to add the A after the function definition to use the ASCII version of the function. The function is part of the user32.dll package.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date