现在定义如下
Public Declare Function CeCreateProcess Lib "rapi.dll"( _
ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
lpProcessAttributes as SECURITY_ATTRIBUTES, _
lpThreadAttributes as SECURITY_ATTRIBUTES, _
bInheritHandles as Boolean, _
ByVal dwCreationFlags As Long, _
lpEnvironment As Any, _
ByVal lpCurrentDirectory as String, _
lpStartupInfo as STARTUPINFO, _
lpProcessInformation as PROCESS_INFORMATION _
) as Boolean
难道写错了?总是不能通过编译,这个是VB6的代码!
这个函数执行后,还有什么要注意的地方吗?
错误信息
compile error
user-defined type not defined
BOOL CeCreateProcess(
LPCWSTR lpApplicationName,
LPCWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPWSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
);
这个是本来的帮助文档里的信息
Dim R As Boolean
R = CeCreateProcess("\Program Files\SetTime\SetTime.exe", "", "", False, 0, "", "", "", "", "")
Command6.Caption = R
这样执行也报错,
LPSECURITY_ATTRIBUTES lpProcessAttributes
给了默认值Null怎么会报参数类型不匹配的错误!
上面的应该是Dim R As Boolean
R = CeCreateProcess("\\Program Files\\SetTime\\SetTime.exe", "", "", False, 0, "", "", "", "", "")
Command6.Caption = R
要双斜杠的吧??
vb6,不是C sharp,呵呵,提示参数类型不匹配!
BOOL CeCreateProcess(
LPCWSTR lpApplicationName,
LPCWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPWSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation);
仔细看下,应该是你没用Unicode的缘故! 这样改试试:
Dim R As Boolean
R = CeCreateProcess(L"\Program Files\SetTime\SetTime.exe", L"", L"", False, 0, L"", L"", L"", L"", L"")
Command6.Caption = R
如果VB下也有类似TEXT这样的宏,则用宏比较好.
这个问题,我一直没有解决!看了一些文档,发现许多人都说这个方法是有问题的!