954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

2 Exes with code :)

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
#include
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( π, 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.
π ) // 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!

Max721
Newbie Poster
5 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

Apparently, you didn't know you should have used code tags either, despite all the places where it gets mentioned.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You