Windows Process ID: Difference between revisions
Created |
m spelling |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
The '''Windows Process ID''' of a [[Visual DataFlex]] program is something it is sometimes useful to be able to retrieve in order to determine which of | The '''Windows Process ID''' of a [[Visual DataFlex]] program is something it is sometimes useful to be able to retrieve in order to determine which of several process has done something, especially in the context of logging activity or events, say in the situation of a [[Web_Application|WebApp]] or [[Web Services|Web Service]] where a pool of identical processes are servicing user client requests, as it uniquely identifies the running process. | ||
It might also be used to determine which process to | It might also be used to determine which process to | ||
Line 8: | Line 8: | ||
Retrieving the Process ID involves calling a Windows API function in '''Kernel32.dll''', defined in your code as follows: | Retrieving the Process ID involves calling a Windows API function in '''Kernel32.dll''', defined in your code as follows: | ||
<source lang="vdf"> | |||
External_Function GetCurrentProcessID "GetCurrentProcessId" Kernel32.dll Returns DWord | |||
</source> | |||
('''Note''' that the terminal "'''d'''" of "''GetCurrentProcessId''" is ''lower-case'' and External Function calls are case-sensitive - something that caused me to fail to get it working for some time! --[[User:Mikepeat|Mike]]) | ('''Note''' that the terminal "'''d'''" of "''GetCurrentProcessId''" is ''lower-case'' and External Function calls are case-sensitive - something that caused me to fail to get it working for some time! --[[User:Mikepeat|Mike]]) | ||
Line 14: | Line 16: | ||
Then in order to determine the Process ID you need only use something like: | Then in order to determine the Process ID you need only use something like: | ||
<source lang="vdf"> | |||
Set piProcessID to (GetCurrentProcessID()) | |||
</source> | |||
[[Category:Cookbook]] | [[Category:Cookbook]] |
Latest revision as of 16:58, 19 December 2008
The Windows Process ID of a Visual DataFlex program is something it is sometimes useful to be able to retrieve in order to determine which of several process has done something, especially in the context of logging activity or events, say in the situation of a WebApp or Web Service where a pool of identical processes are servicing user client requests, as it uniquely identifies the running process.
It might also be used to determine which process to kill using Windows Task Manager (in the "Processes" tab the Process ID is shown in the PID column; select the one causing the problem, then click the "End Process" button and confirm) in the event that one of a number of processes is causing a problem.
A program or object need only retrieve the Windows Process ID once, at start-up, because of course it doesn't change.
Retrieving the Process ID involves calling a Windows API function in Kernel32.dll, defined in your code as follows:
External_Function GetCurrentProcessID "GetCurrentProcessId" Kernel32.dll Returns DWord
(Note that the terminal "d" of "GetCurrentProcessId" is lower-case and External Function calls are case-sensitive - something that caused me to fail to get it working for some time! --Mike)
Then in order to determine the Process ID you need only use something like:
Set piProcessID to (GetCurrentProcessID())