comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » how can i get parent process pid on windows using IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: how can i get parent process pid on windows using IDL [message #90598 is a reply to message #90597] Thu, 12 March 2015 23:16 Go to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Thu, 12 Mar 2015 19:45:46 -0700 (PDT), Dae-Kyu Shin wrote:

> 2015? 3? 12? ??? ?? 11? 11? 34? UTC+9, Jim P ?? ?:
>> On Thursday, March 12, 2015 at 7:38:48 AM UTC-6, Dae-Kyu Shin wrote:
>>> hi
>>>
>>> how can i get parent process pid on windows?
>>>
>>> for example
>>>
>>> in windows cmd
>>>
>>> wmic process get processid, parentprocessi
>>>
>>> in IDL
>>>
>>> spawn, 'wmic process get processid, parentprocessid', result
>>>
>>> but this is not working
>>>
>>> is there another way??
>>>
>>> thanks
>>
>> Try this:
>> PRINT, CALL_EXTERNAL('kernel32.dll', 'GetCurrentProcessId')
>>
>> Jim P
>
> thanks
> i can get pid using kernel32.dll but this is not ppid(parent process id).
> is thete another function for ppid in kernel32.dll?

The problem seems to be, that the Windows wmic command returns an
unicode string ("wide char"). The IDL spawn command stops reading this
string at the first null byte.

You can try to redirect the result from wmic into a temporary file:
spawn,'wmic process get processid, parentprocessid >result.txt'

Then read the file into a binary array and convert the array into an
ASCII string:
openr,lun,/get_lun,'result.txt'
arr=bytarr((fstat(lun)).size)
readu,lun,arr
free_lun,lun
arr=arr[2:*] ; skip the BOM
arr=arr[0:*:2] ; assume all unicode chars to be ASCII
pos=where(arr eq 13b and arr[1:*] eq 10b) ; positions of CRLF
start=[0,pos[0:-2]+2] ; start positions of lines
len=pos-start ; lengths of lines
str=strmid(arr,start,len)
print,str

Is this what you need?

Cheers, Heinz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: cgsnapshot-->dialog_pickfile:Bad initial filename
Next Topic: supervised classification

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:45:10 PDT 2025

Total time taken to generate the page: 0.00383 seconds