当前位置: 代码迷 >> PB >> PBNI的RunApplication获取CommandParm解决办法
  详细解决方案

PBNI的RunApplication获取CommandParm解决办法

热度:242   发布时间:2016-04-29 05:19:17.0
PBNI的RunApplication获取CommandParm
最近在研究PBNI,使用示例代码RunApplication,发现虽然传入了CommandLine但是PB端用CommandParm()根本获取不了这个传入的参数,哪里不对?
代码如下,要获取szcommandline 传入的102 110,但是CommandParm()返回空。
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
                 IPB_Session* session = NULL;
// Provide command line parameters (employee ids)
// to be passed to the PowerBuilder application
LPCTSTR szcommandline = "102 110";
int wmId, wmEvent, ret;
PAINTSTRUCT ps;
HDC hdc;
HINSTANCE hPBVMInst = ::LoadLibrary("pbvm90.dll");
P_PB_GetVM getvm = (P_PB_GetVM)
GetProcAddress(hPBVMInst,"PB_GetVM");
IPB_VM* vm = NULL;
getvm(&vm);
static const char *liblist [] = {"runapp.pbd"};
vm->RunApplication("runapp", liblist, 1,szcommandline, &session);

session->Release();
FreeLibrary(hPBVMInst);

system("PAUSE");
}

------解决思路----------------------
pbni还真没仔细研究过,帮你Up一下
------解决思路----------------------
RunApplication之前,貌似需要先CreateSession
------解决思路----------------------

LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
                 IPB_Session* session = NULL;
        // Provide command line parameters (employee ids)
        // to be passed to the PowerBuilder application
        LPCTSTR szcommandline = "102 110";
        int wmId, wmEvent, ret;
        PAINTSTRUCT ps;
        HDC hdc;
        HINSTANCE hPBVMInst = ::LoadLibrary("pbvm90.dll");
        P_PB_GetVM getvm = (P_PB_GetVM)
        GetProcAddress(hPBVMInst,"PB_GetVM");
        IPB_VM* vm = NULL;
        getvm(&vm);
        static const char *liblist [] = {"runapp.pbd"};
PBXRESULT ret= vm->CreateSession("runapp", liblist, 1, &session);
if (ret == PBX_OK) {  
vm->RunApplication("runapp", liblist, 1,szcommandline, &session);
return 0;
}
                 
        session->Release();
        FreeLibrary(hPBVMInst);
 
        system("PAUSE");
}


------解决思路----------------------
你可以转换一下方式,将Application的Open事件中的代码挪移到一个全局函数中,然后在C++中调用这个全局函数
  相关解决方案