Hello all,
I am having a bit of a problem working with very simple c++ rules regarding the Windows API functions.
I understand why a struct must be initialized but am having problems doing so using the Windows API's.
Now if you look where I am using the ZeroMemory() function, I was just trying to make things work.
I know that normally the syntax is something along these lines for initializing your structs size:
PROCESS_INFORMATION pi = sizeof(PROCESS_INFORMATION);
or
PROCESS_INFORMATION pi = sizeof(STRUCTURE HERE); // Pseudo'ish
So can anyone provide me the clarification on correctly initializing any structs size so I can continue reading my book and working through the examples? It seems every example I run into the compiler keeps telling me I am doing things wrong. When I search on the MSDN, I rarely find the answer I am looking for. Thanks to all in advance for the clarification.
Oh by the way, this code is giving me an error 87, which is ERROR_INVALID_PARAMETER "The parameter is incorrect."
Here is my code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <Windows.h>
#include <iostream>
#include "Utilities.h"
using namespace std;
void main()
{
Util::Utilities ut;
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(&pi));
CreateProcess((LPCWSTR)"f:\program files\ventrilo.exe",
NULL,
NULL,
NULL,
TRUE,
CREATE_NO_WINDOW,
NULL,
NULL,
NULL,
&pi);
cout << GetLastError() << endl;
ut.wait();
}
|