Wednesday, August 1, 2007

在CE下自動開啟目錄

沒想到msdn library有CreateDirectory, RemoveDirectory
但就是沒有OpenDirectory
還好達哥之前有寫過
不然這個方法我大概要找很久吧 orz

void OpenFolder()
{
HWND hwnd;
SHELLEXECUTEINFO si;

memset (&si, 0, sizeof (si));
si.cbSize = sizeof (si);
si.fMask = 0;
si.hwnd = hwnd;
si.lpFile = TEXT ("\\My Flash Disk\\PEtestfolder"); //要開啟的資料夾
si.lpVerb = TEXT ("explore"); //特定參數

ShellExecuteEx (&si);
}

lpVerb
Long pointer to a string specifying the name of a verb. The verb specifies an action for the application to perform. The set of available verbs depends on the particular file or folder. It includes the commands listed in the context menu and the registry. The following table shows verbs that are usually valid.
Value Description
Edit The function opens an editor.
Find The function initiates a search starting from the specified directory.
Open The function opens the file specified by the lpFile parameter. The file can be an executable file or a document file. It can also be a folder. This is the default verb if no verb is specified.
Print The function prints the document file specified by lpFile.

其他的verbs要參考registry的HKEY_CLASSES_ROOT\object_name\Shell\verb

不懂的是explore這個參數是哪來的,如果設Open會不會有一樣的結果?
試了之後發現
也是可以的!

0 comments: