LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get the process ID (pid)

Is there a way to get the 'process id' in LV?
Message 1 of 11
(7,537 Views)
Hi codas
Basically, you have ways to get prcesses id:
1.- If using Lv 7.x,.NET could be a good choice. See example about task manager and modifie to get ID too.

2. If not ( or if you like), use system exec.vi to call TASKLIST.EXE.You will get the list of processes as in the windows task manager.

3.- Calling the apropiate DLL. (Look at microsoft doc)

Hope it helps.
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
Message 2 of 11
(7,537 Views)
Call:

HANDLE GetCurrentProcess(VOID);

Or:

DWORD GetCurrentProcessId(VOID);

Both from kernel32.dll

Dll's don't get easier then this.

Regards,

Wiebe.


"codas" wrote in message
news:5065000000080000001CEB0000-1079395200000@exchange.ni.com...
> Is there a way to get the 'process id' in LV?
Message 3 of 11
(7,537 Views)

Hi alipio,

I have same question. I do find tasklist is useful, but i don't know how to pass the PID value to a variable so that i can locate the particular process from several processes that have same name. I'm using LV 6.0. Is there any function that LV provide can pass the PID value to a variable? Thanks a lot!

0 Kudos
Message 4 of 11
(6,296 Views)

What about the post from Wiebe doesn't help you? He showed the Windows APIs to call to get what the title of the post describes. Even LabVIEW 6 has a Call Library Node that can call those Windows APIs.

But from the sound of it you may actually have a different problem and then you should not attach your post to an existing only very loosely related thread, and it is also not very useful to resurrect a 13 year old thread anyways. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 11
(6,286 Views)

Hello,  I could get process id with LabVIEW  VI (2021 SP1) at Windows.

I input command in System Exec.vi

 

- tasklist /FI "ImageName eq LabVIEW.exe" /FI "Status eq Running" /FO LIST

 

Then I used two VI's for regular expression.

-  PID:.*\d+

-  \d+

 

I also attached figure of block diagram. 

Is this good way to get process id?

 

0 Kudos
Message 6 of 11
(3,839 Views)

@matumot wrote:

Hello,  I could get process id with LabVIEW  VI (2021 SP1) at Windows.

I input command in System Exec.vi

 

- tasklist /FI "ImageName eq LabVIEW.exe" /FI "Status eq Running" /FO LIST

 

Then I used two VI's for regular expression.

-  PID:.*\d+

-  \d+

 

I also attached figure of block diagram. 

Is this good way to get process id?

 


I am unsure what you are asking.  If you have a specific question about the snippet you attached you should create a new thread.  That would make it much easier for everyone to help you.  You seem to have mistakenly replied to a thread that started 17 1/2 years ago.

 

LabVIEW, Computer processers and Operating systems have evolved dramatically over those last decades!  In fact, the Original Poster hasn't even logged into these forums for over 12 years! So, it's unlikely your example will help codas.

(Besides snippets in 2020 won't open in 6.i for SO many reasons)

 

I could split this thread or you might just add a link to your new thread if you have a specific problem. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 11
(3,792 Views)

ok,  my answer may be just a reply to first question,  and  mistakenly replied as you suggested.  (my solution is very simple and may be adopted for labview with older verion,  though I know labview is now targeted for subscription usage)

 

> Is there a way to get the 'process id' in LV?

0 Kudos
Message 8 of 11
(3,781 Views)

One thing you need to watch out when using command lind tools is the fact that they are usually localized. This means that the output they generate can significantly differ depending on the country setting of the Windows installation or even currently logged in user. That can make parsing more complicated if it ever gets executed on a different system.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 11
(3,770 Views)

I tested my code in japanese windows10 system, and it was ok.

But your indication can be correct.

 

> That can make parsing more complicated if it ever gets executed on a different system.

 

0 Kudos
Message 10 of 11
(3,736 Views)