怎样在⼀个项⽬中引⽤另⼀个项⽬的⽂件
有⼀个函数:
ShellExecute Function
Performs an operation on a specified file.
Syntax
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
Parameters
hwnd
createprocessa[in] A handle to the owner window used for displaying a user interface (UI) or error messages. This value
can be NULL if the operation is not associated with a window.
lpOperation
[in] A pointer to a null-terminated string, referred to in this case as a verb, that specifies the action to be
performed. The set of available verbs depends on the particular file or folder. Generally, the actions
available from an object's shortcut menu are available verbs. The following verbs are commonly use
d.
edit
Launches an editor and opens the document for editing. If lpFile is not a document file, the
function will fail.
explore
Explores a folder specified by lpFile.
find
Initiates a search beginning in the directory specified by lpDirectory.
open
Opens the item specified by the lpFile parameter. The item can be a file or folder.
print
Prints the file specified by lpFile. If lpFile is not a document file, the function fails.
NULL
In systems prior to Microsoft Windows 2000, the default verb is used if it is valid and available
in the registry. If not, the "open" verb is used.
In Windows 2000 and later, the default verb is used if available. If not, the "open" verb is used. If
neither verb is available, the system uses the first verb listed in the registry.
lpFile
[in] A pointer to a null-terminated string that specifies the file or object on which to execute the specified verb. To specify a Shell namespace object, pass the fully qualified parse name. Note that not all verbs are
上⾯是MSDN⾥对ShellExecute()函数的解释~其中注意:
1. lpDirectory 和lpFile中只能有⼀个⽤相对路径,也就是说,如果把默认参数不加改动,都⽤NULL的话,那个lpFile⼀定要⽤绝对路径(不知道我理解的对不对,⾄少实验出来是这样的)。
2. 在写绝对路径的时候,每个/都要再加⼀个/,否则读取时会吃掉⼀个/导致读不出来
3. 举个例⼦:::ShellExecute(NULL,(CString)"open",(CString)"C://Documents and Settings//张睿卿//My Documents//Visual Studio 2008//Projects//whole//",NULL,NULL,SW_SHOWNORMAL);
4. 张华哥哥教我的⼀种⽅法!嘻嘻!
把.exe⽂件放⼊要调⽤的⼯程⽂件夹⾥,然后把路径就可以改为..//了!
::ShellExecute(NULL,(CString)"open",(CString)"..//",NULL,NULL,SW_SHOWNORMAL);
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论