cancel
Showing results for 
Search instead for 
Did you mean: 

Main Window Handle or Process ID of the current B1 client instance

Former Member
0 Kudos

Does anyone know how to get either the Main Window Handle or the Windows Process ID of the current B1 client session. GetProcessesByName("SAP Business One") will not work if there is more than one B1 Session Open.

Any help is appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You may check this:

Thanks,

Gordon

Answers (2)

Answers (2)

Former Member
0 Kudos

Petr,

Thanks for your reply. It appears that your code will get the process id of the addon, but I need the process id of the current instance of SAP Business One. Am I missing something?

Former Member
0 Kudos

No, its id of SAP, not addon, but this code works only when you will compile addon, in debug mode the process is visual studio.

Former Member
0 Kudos

Im doing it so:

Dim myProcess As System.Diagnostics.Process = System.Diagnostics.Process.GetCurrentProcess()

Dim ProccessInfo As New Process_Basic_Information

Dim ProcHandle As IntPtr = Process.GetProcessById(myProcess.Id).Handle

Dim RetLength As UInteger

NtQueryInformationProcess(ProcHandle, PROCESSBASICINFORMATION, ProccessInfo, Marshal.SizeOf(ProccessInfo), RetLength)