void COutRunDlgDlg::OnRun()
{
CString pszDllName="shell32.dll";
HINSTANCE hLib = ::LoadLibrary(pszDllName);
typedef void (__stdcall *pRunFileDlg)(HWND, HICON, LPCTSTR, LPCTSTR, LPCTSTR, UINT);
pRunFileDlg RunFileDlg;
if (hLib==NULL)
{
return ;
}
RunFileDlg = (pRunFileDlg)GetProcAddress(hLib, (char *)61);
CString name ="wolfbaby的运行";
CString sss = "输入程序路径";
LPWSTR wname=new WCHAR[100];
LPWSTR wsss=new WCHAR[100];
memset(wname,0,sizeof(WCHAR)*100);
memset(wsss,0,sizeof(WCHAR)*100);
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED, // character-type options
name, // address of string to map
name.GetLength(), // number of bytes in string
wname, // address of wide-character buffer
100
);
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED, // character-type options
sss, // address of string to map
sss.GetLength(), // number of bytes in string
wsss, // address of wide-character buffer
100
);
if(RunFileDlg!=NULL)
{
RunFileDlg(this->GetSafeHwnd(),NULL,NULL,(LPCTSTR)wname,(LPCTSTR)wsss,0x02);
}
::FreeLibrary(hLib);
delete []wname;
delete []wsss;
}
void COutRunDlgDlg::OnRestar()
{
CString pszDllName="shell32.dll";
HINSTANCE hLib = ::LoadLibrary(pszDllName);
typedef void (__stdcall *pRunFileDlg)(HWND, LPCTSTR, UINT);
pRunFileDlg RunFileDlg;
if (hLib==NULL)
{
return ;
}
RunFileDlg = (pRunFileDlg)GetProcAddress(hLib, (char *)59);
CString name ="wolfbaby重启";
wchar_t *wname=new WCHAR[100];
memset(wname,0,sizeof(WCHAR)*100);
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED, // character-type options
name, // address of string to map
name.GetLength(), // number of bytes in string
wname, // address of wide-character buffer
100
);
if(RunFileDlg!=NULL)
{
RunFileDlg(this->GetSafeHwnd(),(LPCTSTR)wname,0x02);
}
::FreeLibrary(hLib);
delete []wname;
}
本文介绍了一种通过加载shell32.dll并调用其内部函数来创建自定义的文件运行对话框的方法。该方法适用于Windows平台的应用程序,能够帮助用户选择并执行特定的程序路径。
1万+

被折叠的 条评论
为什么被折叠?



