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 
Switch to threaded view of this topic Create a new topic Submit Reply
how can i get parent process pid on windows using IDL [message #90585] Thu, 12 March 2015 06:38 Go to next message
Dae-Kyu Shin is currently offline  Dae-Kyu Shin
Messages: 25
Registered: February 2015
Junior Member
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
Re: how can i get parent process pid on windows using IDL [message #90586 is a reply to message #90585] Thu, 12 March 2015 07:11 Go to previous messageGo to next message
Jim  Pendleton is currently offline  Jim Pendleton
Messages: 165
Registered: November 2011
Senior Member
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
Re: how can i get parent process pid on windows using IDL [message #90597 is a reply to message #90586] Thu, 12 March 2015 19:45 Go to previous messageGo to next message
Dae-Kyu Shin is currently offline  Dae-Kyu Shin
Messages: 25
Registered: February 2015
Junior Member
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?
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
  Switch to threaded view of this topic Create a new topic Submit Reply
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 07:14:40 PDT 2025

Total time taken to generate the page: 0.00421 seconds