Skip to Content
author's profile photo
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on May 03, 2011 at 09:15 PM

    Hi,

    You may check this: get-sbo-process-id-on-terminal-server

    Thanks,

    Gordon

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on May 04, 2011 at 05:53 AM

    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)

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on May 04, 2011 at 05:07 PM

    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?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.