I didnt know i must post code here so sry everyone :).
So my problem is next: I have two exes that need to excange data. I tried using standard ::CreateProcess() and ::GetProcAdress() functions but got errors. I presume thats becouse exes are in different processes. I cant use COM for communication heres code
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using std::cout;
using std::cin;
#define EXPORT __declspec(dllexport)
typedef int(*BLA);
//typedef int (__stdcall *myFunc)(const int*);
int _tmain(int argc, _TCHAR* argv[])
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( TEXT("d.exe"), // 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.
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
}
else
{
//cout<<" Main application succeeded in loading exe!\n";
BLA l=(BLA)::GetProcAddress((HMODULE)pi.hProcess,"a");
if(l)
cout<<*l;
else
cout<<::GetLastError();
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
//cout<<*l;
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
char c;
cin>>c;
return 0;
}
please help. Thanks in advance!