关于桌面上文件的执行,急! 一个函数搞定BOOL ShellExecuteEx( LPSHELLEXECUTEINFO lpExecInfo); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对呀,很easy.ShellExecute(...)指定程序路径不就解决了吗? 还可以用CreateProcessBOOL CreateProcess( LPCTSTR lpApplicationName, // name of executable module LPTSTR lpCommandLine, // command line string LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD BOOL bInheritHandles, // handle inheritance option DWORD dwCreationFlags, // creation flags LPVOID lpEnvironment, // new environment block LPCTSTR lpCurrentDirectory, // current directory name LPSTARTUPINFO lpStartupInfo, // startup information LPPROCESS_INFORMATION lpProcessInformation // process information); 我!想要的就是文件路径。littlecatie(tryer)请具体说一下,中文 在OnButtonClick事件中写如下代码,就可以在单击按钮时运行myprogram: STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); CreateProcess("D:\\Documents and Settings\\catie\\桌面\\myprogram.exe", "MyChildProcess", // Command line. 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 ); SHGetSpecialFolderLocationShellExecute 或者这样也可以:ShellExecute(NULL,"open","D:\\Documents and Settings\\catie\\桌面\\vbreporttest.exe",NULL,NULL,SW_SHOW ); ShellExecute(……)是不是只能执行*.exe文件?“我的电脑”是哪个exe文件啊? HRESULT hr; LPMALLOC pMalloc = NULL; LPITEMIDLIST pidl= NULL; VARIANT vPIDL = {0}, vDummy = {0}; SHELLEXECUTEINFO sei; if (FAILED(OleInitialize(NULL))) { return; } // Get the pidl for your favorite special folder, // in this case literally, the Favorites folder if (FAILED(hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES , &pidl))) { goto Error; } ZeroMemory(&sei, sizeof(sei)); sei.cbSize = sizeof(sei); sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME; sei.lpIDList = pidl; sei.lpClass = TEXT("folder"); sei.hwnd = ::GetDesktopWindow(); sei.nShow = SW_SHOWNORMAL; sei.lpVerb = TEXT("explore");//sei.lpVerb = TEXT("open"); ShellExecuteEx(&sei); SHGetMalloc(&pMalloc); if(pMalloc){ pMalloc->Free(pidl); pMalloc->Release(); } 楼上的说啦!用SHGetSpecialFolderLocation来得到你要的虚拟文件夹,得到ITEMIDLIST后,你想这么样就能怎么样啦!这要用到命名空间,详细的找点资料看吧!在Cj60里有这样的例子! 子控件与父窗口间的消息传递 MDI 双击缩略图的小picture控件创建子窗体并且显示这个原图 关于动态链接库的问题! vc++2008 如何为active 添加属性 linux怎么给edit上色???????? 国外有没有VC方面开源项目的站 问一个摄像头视频抓取的问题 PCM格式和ADPCM格式有何不同,如何将pcm转为adpcm格式 有 Active Directory 编程经验的进!谢谢 如何在VC的一个对话框中,实现对DXF文件的预览功能? 关于鼠标的问题,解决了给高分! 求一简单变换,送分题
对呀,很easy.
ShellExecute(...)指定程序路径不就解决了吗?
BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);
littlecatie(tryer)请具体说一下,中文
STARTUPINFO si;
PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) ); CreateProcess("D:\\Documents and Settings\\catie\\桌面\\myprogram.exe",
"MyChildProcess", // Command line.
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 );
ShellExecute
ShellExecute(NULL,"open","D:\\Documents and Settings\\catie\\桌面\\vbreporttest.exe",NULL,NULL,SW_SHOW );
“我的电脑”是哪个exe文件啊?
LPMALLOC pMalloc = NULL;
LPITEMIDLIST pidl= NULL;
VARIANT vPIDL = {0}, vDummy = {0};
SHELLEXECUTEINFO sei; if (FAILED(OleInitialize(NULL)))
{
return;
} // Get the pidl for your favorite special folder,
// in this case literally, the Favorites folder
if (FAILED(hr = SHGetSpecialFolderLocation(NULL,
CSIDL_DRIVES , &pidl)))
{
goto Error;
} ZeroMemory(&sei, sizeof(sei));
sei.cbSize = sizeof(sei);
sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
sei.lpIDList = pidl;
sei.lpClass = TEXT("folder");
sei.hwnd = ::GetDesktopWindow();
sei.nShow = SW_SHOWNORMAL; sei.lpVerb = TEXT("explore");//sei.lpVerb = TEXT("open");
ShellExecuteEx(&sei); SHGetMalloc(&pMalloc);
if(pMalloc){
pMalloc->Free(pidl);
pMalloc->Release();
}
命名空间,详细的找点资料看吧!
在Cj60里有这样的例子!