Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is File Running? Determine on win98
Message
From
08/10/2004 17:10:15
 
 
To
08/10/2004 16:28:14
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00950059
Message ID:
00950066
Views:
13
This has not been tested:

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q192/9/86.asp&NoWebContent=1
#DEFINE myidPROCESS  2
#DEFINE stSIZE  296

DO declall


	CREATE CURSOR myResult (refnum    N(16),;
		procnum   N(16),;
		heapnum      N(16),;
		modnum    N(16),;
		threadnum N(16),;
		pnum    N(16),;
		priornum    N(16),;
		nflags       N(16),;
		procname    C(250))

	LOCAL LCaptureIt, lcBuffer

	LCaptureIt = CreateToolhelp32SnapShot(myidPROCESS, 0)
	lcBuffer = num2dword(stSIZE) + Repli(Chr(0), stSIZE-4)

	IF Process32First (LCaptureIt, @lcBuffer) = 1
		= saveProcessData (lcBuffer)

		DO WHILE .T.
			IF Process32Next (LCaptureIt, @lcBuffer) = 1
				= saveProcessData (lcBuffer)
			ELSE
				EXIT
			ENDIF
		ENDDO
	ENDIF

	= CloseHandle (LCaptureIt)
	SELECT myResult
	GO TOP
	BROWSE 
RETURN 

PROCEDURE  saveProcessData (lcBuffer)
	LOCAL m.refnum, m.procnum, m.heapnum, m.modnum, m.threadnum,;
		m.pnum, m.priornum, m.nflags, m.procname;

	m.refnum = buf2dword (SUBSTR(lcBuffer, 5,4))
	m.procnum = buf2dword (SUBSTR(lcBuffer, 9,4))
	m.heapnum = buf2dword (SUBSTR(lcBuffer, 13,4))
	m.modnum = buf2dword (SUBSTR(lcBuffer, 17,4))
	m.threadnum = buf2dword (SUBSTR(lcBuffer, 21,4))
	m.pnum = buf2dword (SUBSTR(lcBuffer, 25,4))
	m.priornum = buf2dword (SUBSTR(lcBuffer, 29,4))
	m.nflags = buf2dword (SUBSTR(lcBuffer, 33,4))
	m.procname = SUBSTR(lcBuffer, 37)
	m.procname = SUBSTR(m.procname, 1, AT(Chr(0),m.procname)-1)

	INSERT INTO myResult FROM MEMVAR
RETURN

FUNCTION  num2dword (lnValue)
#DEFINE m0       256
#DEFINE m1     65536
#DEFINE m2  16777216
	LOCAL b0, b1, b2, b3
	b3 = Int(lnValue/m2)
	b2 = Int((lnValue - b3*m2)/m1)
	b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
	b0 = Mod(lnValue, m0)
RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)

FUNCTION  buf2dword (lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
	Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
	Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
	Asc(SUBSTR(lcBuffer, 4,1)) * 16777216

PROCEDURE  declall
	DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject

	DECLARE INTEGER CreateToolhelp32ShapShot IN kernel32;
		INTEGER dwFlags, INTEGER procnum  

	DECLARE INTEGER Process32First IN kernel32;
		INTEGER hval, STRING @ mystring  

	DECLARE INTEGER Process32Next IN kernel32;
		INTEGER hval, STRING @ mystring
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform