>*===================================================== >* Returns the name of the EXE for a given process ID >*===================================================== >LParameter tnPID > > *-------------------------------------------------- > * Declare WIN-API functions > *-------------------------------------------------- > Declare Integer CreateToolhelp32Snapshot In win32api Integer, Integer > Declare Integer CloseHandle In WIn32Api Integer > Declare Integer Process32First In WIn32APi Integer, String@ > Declare Integer Process32Next In WIn32APi Integer, String@ > > *-------------------------------------------------- > * load struct component > *-------------------------------------------------- > Local oProcessEntry > Set Class to Struct.VCX Additive > oProcessEntry = CreateObject("PROCESSENTRY32") > > *-------------------------------------------------- > * get processes > *-------------------------------------------------- > Local lnHandle, lnRet, lcString, lcStringEmpty, lcEXE > lnHandle = CreateToolhelp32Snapshot(2,0) > lcStringEmpty = oProcessEntry.GetString() > lcEXE = "" > If lnHandle > 0 > lcString = m.lcStringEmpty > lnRet = Process32First(lnHandle,@lcString) > oProcessEntry.SetString(lcString) > Do While lnRet > 0 > If oProcessEntry.nProcessId == m.tnPID > lcEXE = oProcessEntry.cExeFile > Exit > EndIf > lcString = m.lcStringEmpty > lnRet = Process32Next(lnHandle,@lcString) > oProcessEntry.SetString(lcString) > Enddo > CloseHandle(lnHandle) > Endif > > *-------------------------------------------------- > * cleanup > *-------------------------------------------------- > oProcessEntry.Release > >Return m.lcEXE > >*----------------------------------------------------- >* PROCESSENTRY32 Struktur >*----------------------------------------------------- >Define Class PROCESSENTRY32 as Struct > nSize = 296 > nCntUsage = 0 > nProcessID = 0 > nDefaultHeap = 0 > nModuleID = 0 > nCntThreads = 0 > nParentProcessID = 0 > nPriClassBase = 0 > nFlags = 0 > cExeFile = "" > cMembers = "l:nSize,l:nCntUsage,l:nProcessId,"+; > "l:nDefaultHeap,l:nModuleID,l:nCntThreads,"+; > "l:nParentProcessID,L:nPriClassbase,"+; > "l:nFlags,0c260:cExeFile" >Enddefine >>Alternatively, you can use GetProcessImageFileName (http://msdn.microsoft.com/en-us/library/ms683217%28VS.85%29.aspx), but you would need to open the process and pass in the handle.