-
March 31st, 2004, 03:25 PM
#1
Shell Windows Explorer to Specific Folder
Please help. I am trying to open Windows Explorer to specifically browse the Tasks folder from my program. Unfortunately Windows Explorer keeps opening to the "My Documents" folder.
Code:
// Locals
BOOL br=FALSE;
UINT cb=0;
TCHAR tszWinDir[MAX_PATH];
tszWinDir[0]=0;
STARTUPINFO siStartupInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
PROCESS_INFORMATION piProcessInfo;
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
CString strAppPath;
strAppPath = _T("C:\\Winnt"); // default
CString strTasksPath;
strTasksPath = _T("C:\\Winnt"); // default
// Shell Explorer to the task folder
cb = GetWindowsDirectory(tszWinDir, MAX_PATH);
if(cb>0)
{
strAppPath = tszWinDir;
strTasksPath = tszWinDir;
}
strAppPath += _T("\\explorer.exe");
strTasksPath += _T("\\Tasks");
siStartupInfo.cb = sizeof(siStartupInfo);
br = CreateProcess(strAppPath, // Application name
const_cast<TCHAR*>((const TCHAR*)strTasksPath), // Application arguments
0,
0,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
0,
const_cast<TCHAR*>((const TCHAR*)strTasksPath), // Working directory
&siStartupInfo,
&piProcessInfo);
Sincerely,
- Ron
-
March 31st, 2004, 04:53 PM
#2
Well, when I replace the call to create process with the following it works, but I don't know why.
Code:
HINSTANCE hInst = ShellExecute(0,
"open", // Operation to perform
strAppPath, // Application name
strTasksPath, // Additional parameters
0, // Default directory
SW_SHOW);
Sincerely,
- Ron
-
March 31st, 2004, 05:17 PM
#3
Code:
STARTUPINFO siStartupInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
PROCESS_INFORMATION piProcessInfo;
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
CString strAppPath;
LPTSTR pBuf = strAppPath.GetBufferSetLength(MAX_PATH);
GetWindowsDirectory(pBuf, MAX_PATH);
strAppPath.ReleaseBuffer();
CString strTasksPath = " /e, /root, ";
strTasksPath += strAppPath;
strTasksPath += _T("\\Tasks");
strAppPath += _T("\\explorer.exe");
siStartupInfo.cb = sizeof(siStartupInfo);
if(!CreateProcess(strAppPath, // Application name
(LPTSTR)(LPCTSTR)strTasksPath, // Application arguments
0,
0,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
0,
NULL, // Working directory
&siStartupInfo,
&piProcessInfo))
{
AfxMessageBox("CreateProcess failed.");
DWORD dw = GetLastError();
}
Will open Tasks as root directory.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
March 31st, 2004, 06:54 PM
#4
Like this.
Code:
CString cmdLine = strAppPath + CString(" ") + strTasksPath;
br = CreateProcess(NULL, // Application name
cmdLine, 0,
0,
FALSE,
CREATE_DEFAULT_ERROR_MODE,
0,
const_cast<TCHAR*>((const TCHAR*)strTasksPath), // Working directory
&siStartupInfo,
&piProcessInfo);
Best Api Monitor tool.
Trace the target program automatically and monitor the parameters of all API and COM interfaces.
Auto Debug for Windows 4.0
Auto Debug for .Net
http://www.autodebug.com/
-
April 1st, 2004, 10:37 AM
#5
That is too wierd. Twas the extra space that did it.
Thank you both for your replies.
Sincerely,
- Ron
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|