javaloader.cpp

来自「发布java应用程序的同时发布jdk」· C++ 代码 · 共 38 行

CPP
38
字号
#include <afxwin.h>
int __stdcall WinMain( HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpszCmdLine,
    int nCmdShow )
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
 
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi) );
 
    // Start the child process. 
    if( !CreateProcess( "jre\\bin\\javaw.exe",//执行的程序名
                        "jre\\bin\\javaw.exe -jar MyApp.jar", // 带参数的执行程序
            NULL,             // Process handle not inheritable. 
            NULL,             // Thread handle not inheritable. 
            FALSE,            // Set handle inheritance to FALSE. 
            0,                // No creation flags. 
            NULL,             // Use parent's environment block. 
            NULL,             // Use parent's starting directory. 
            &si,              // Pointer to STARTUPINFO structure.
            &pi)             // Pointer to PROCESS_INFORMATION structure.
    ) 
    {
            //AfxMessageBox("应用程序启动失败!");
		return 0;
    }
 
    // Wait until child process exits.
    WaitForSingleObject(pi.hProcess, INFINITE );
 
    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
	return 0;
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?