Mr KOP
T.E.T.Я.I.S
- 11/3/07
- 507
- 18
mình có đoạn code sau
khi chạy thì nó báo không thể chuyển kiểu char qua LPCWSTR
nguyên văn như sauerror C2664: 'CreateProcessW' : cannot convert parameter 1 from 'char [31]' to 'LPCWSTR'
Mấy bro giải thích và sửa hộ với
cảm ơn trước
ps: mình có tìm trên mấy trang nước ngoài cũng có nói về chuyển qua lại giữa chả và LPCWSTR nhưng đọc không hiểu :(
Mã:
#include <stdio.h>
#include <conio.h>
#include <windows.h>
char path[] = "C:\\WINDOWS\\system32\\notepad.exe" ;
int main()
{
PROCESS_INFORMATION pif;
STARTUPINFO si;
printf("Current Process ID = %d\n", GetCurrentProcessId());
ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);
// creat a process to run notepad
printf("Creat a process to run notepad\n");
CreateProcess( path, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pif);
printf("process notepad id: %d\n", GetProcessId(pif.hProcess));
printf("Press any key to terminate notepad ...\n");
getch();
TerminateProcess(pif.hProcess,0);
CloseHandle(pif.hProcess);
CloseHandle(pif.hThread);
ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);
printf("Creat a process to run notepad\n");
CreateProcess( path, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pif);
printf("Waiting for notepad terminated\n");
WaitForSingleObject(pif.hProcess, INFINITE);
CloseHandle(pif.hProcess);
CloseHandle(pif.hThread);
return 0;
}
khi chạy thì nó báo không thể chuyển kiểu char qua LPCWSTR
nguyên văn như sauerror C2664: 'CreateProcessW' : cannot convert parameter 1 from 'char [31]' to 'LPCWSTR'
Mấy bro giải thích và sửa hộ với
cảm ơn trước
ps: mình có tìm trên mấy trang nước ngoài cũng có nói về chuyển qua lại giữa chả và LPCWSTR nhưng đọc không hiểu :(