Visual c++ 从Visual C+;启动.exe+;2005动态链接库 有人知道代码或有关于如何使用Visual C++ 2005启动exe的想法。< /P>
如果是Windows Mobile,则dll所在的环境。使用P/Invoke执行此操作的c [DllImport(“coredll.Dll”)] 私有静态外部int CreateProcess(字符串strimagname、字符串strCmdLine、IntPtr-pProcessAttributes、IntPtr-pthreadtributes、intbinheritsHandle、intdwcreationFlags、IntPtr-pEnvironment、IntPtr-pccurrentdir、Byte[]bArray、ProcessInfo-oProc) //c#启动.exe的代码 CreateProcess(“\Program Files\myprogram\myprogram.exe.exe”,”,IntPtr.Zero,IntPtr.Zero,0,0,IntPtr.Zero,IntPtr.Zero,新字节[128],pi) < >我之所以需要C++是因为在运行自定义的CAB安装程序时,我不得不使用本地DLL来执行前后检查等。< /P> 非常感谢你的想法。Visual c++ 从Visual C+;启动.exe+;2005动态链接库 有人知道代码或有关于如何使用Visual C++ 2005启动exe的想法。< /P>,visual-c++,windows-mobile,compact-framework,pinvoke,Visual C++,Windows Mobile,Compact Framework,Pinvoke,如果是Windows Mobile,则dll所在的环境。使用P/Invoke执行此操作的c [DllImport(“coredll.Dll”)] 私有静态外部int CreateProcess(字符串strimagname、字符串strCmdLine、IntPtr-pProcessAttributes、IntPtr-pthreadtributes、intbinheritsHandle、intdwcreationFlags、IntPtr-pEnvironment、IntPtr-pccurrentd
Tony如果您是指在设备上运行exe,那么任何visual studio都不能直接执行。您需要设置自定义生成步骤或预/后生成步骤来运行将为您执行此操作的应用程序。您可以使用WM5 SDK代码示例(或创建自己的示例)。PRun用于在设备上运行应用程序,因此设备需要通过ActiveSync连接才能正常工作 如果您试图在设备上“自动”进行测试(例如单元测试),您可能希望查看运行。这可能比尝试使用物理设备带来更多好处。尝试以下方法:
BOOL RunExe(CString strFile)
{
WIN32_FIND_DATA fd;
HANDLE hFind;
BOOL bFind;
hFind = FindFirstFile(strFile, &fd);
bFind = (hFind != INVALID_HANDLE_VALUE);
if(bFind)
{
if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
SHELLEXECUTEINFO info;
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.hwnd = 0;
info.lpVerb = _T("open");
info.lpFile = strFile;
info.lpParameters = NULL;
info.lpDirectory = NULL;
info.nShow = SW_SHOW;
info.hInstApp = NULL;
ShellExecuteEx(&info);
}
else
bFind = FALSE;
}
FindClose(hFind);
return bFind;
}
你为什么要用CString的重量来做这样的事情?
BOOL RunExe(CString strFile)
{
WIN32_FIND_DATA fd;
HANDLE hFind;
BOOL bFind;
hFind = FindFirstFile(strFile, &fd);
bFind = (hFind != INVALID_HANDLE_VALUE);
if(bFind)
{
if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
SHELLEXECUTEINFO info;
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.hwnd = 0;
info.lpVerb = _T("open");
info.lpFile = strFile;
info.lpParameters = NULL;
info.lpDirectory = NULL;
info.nShow = SW_SHOW;
info.hInstApp = NULL;
ShellExecuteEx(&info);
}
else
bFind = FALSE;
}
FindClose(hFind);
return bFind;
}