How To Launch BTSuperPak Programs
from other programming languages


eVC++ Example:

//Launch the program
PROCESS_INFORMATION pi;
DWORD rc = CreateProcess (_T("\\Windows\\Start Menu\\BTAutoSync.exe"),
                                            _T("dev=MyDesktop"),
                                            NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi);

if (rc == 0)
    return; //Error launching program

//Wait for it to complete
DWORD dwExitCode;
while (::GetExitCodeProcess (pi.hProcess, &dwExitCode) )
{
    if (dwExitCode == STILL_ACTIVE)
        Sleep(100);

    else
        break;
}

//Close process
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);

 

eVB Example:

Public Function RunShell(cmdline As String, cmdLineArgs As String) As Long

Dim hProcess As Long
Dim ProcessId As Long
Dim exitCode As Long
Dim vntReturn As Variant

vntReturn = ShellEx(cmdline, cmdLineArgs)

If vntReturn(0) = 0 Then
    ProcessId = vntReturn(1)

    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)

    Do
        Call GetExitCodeProcess(hProcess, exitCode)
        CEDoAllEvents

    Loop While exitCode = STATUS_PENDING

    Call CloseHandle(hProcess)
End If

RunShell = vntReturn(0)

End Function