Ayuda con un thread!!!
Publicado por Jaime Martinez (1 intervención) el 29/08/2008 06:13:30
Hola a todos,
soy nuevo en esto de la programacion usando la api de windows y la verdad solo he visto en una clase y pues no le entiendo muy bien si alguien me puede ayudar se los agradeceria intento abrir dos programas a partir un thread pero pues no puedo ni siquiera hacer que se abra uno les paso el codigo y si alguiejn me puede ayudar de verdad estare eternamente agradecido jeje
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <strsafe.h>
DWORD WINAPI funcion(LPVOID lparam)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
TCHAR* nombre;
nombre=(TCHAR*) lparam;
CreateProcess( nombre, // No module name (use command line)
NULL, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ); // Pointer to PROCESS_INFORMATION structure
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
int main ()
{
TCHAR* note = L"C:\WINDOWS\system32\notepad.exe";
TCHAR* calc = L"C:\WINDOWS\system32\calc.exe";
HANDLE hThread;
DWORD dwThreadId;
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
funcion, // thread function name
calc, // argument to thread function
0, // use default creation flags
&dwThreadId);//&dw[0]); // returns the thread identifier
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
funcion, // thread function name
note, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
CloseHandle (hThread);
return 0;
}
me marca el error c2664 en el ´parametro 3 de create thread
cualkier sugerencia ayuda o lo quesea sdera bienvenida
gracias
soy nuevo en esto de la programacion usando la api de windows y la verdad solo he visto en una clase y pues no le entiendo muy bien si alguien me puede ayudar se los agradeceria intento abrir dos programas a partir un thread pero pues no puedo ni siquiera hacer que se abra uno les paso el codigo y si alguiejn me puede ayudar de verdad estare eternamente agradecido jeje
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <strsafe.h>
DWORD WINAPI funcion(LPVOID lparam)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
TCHAR* nombre;
nombre=(TCHAR*) lparam;
CreateProcess( nombre, // No module name (use command line)
NULL, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ); // Pointer to PROCESS_INFORMATION structure
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
int main ()
{
TCHAR* note = L"C:\WINDOWS\system32\notepad.exe";
TCHAR* calc = L"C:\WINDOWS\system32\calc.exe";
HANDLE hThread;
DWORD dwThreadId;
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
funcion, // thread function name
calc, // argument to thread function
0, // use default creation flags
&dwThreadId);//&dw[0]); // returns the thread identifier
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
funcion, // thread function name
note, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
CloseHandle (hThread);
return 0;
}
me marca el error c2664 en el ´parametro 3 de create thread
cualkier sugerencia ayuda o lo quesea sdera bienvenida
gracias
Valora esta pregunta


0