Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't add to pointers.

Status
Not open for further replies.

jcisco2

Programmer
Apr 13, 2004
102
US
I'm wondering how to occumiplish this task in C++. what i would like to do is pass two values to another exe. but Every time I go to compile this application I get an error that tells me that I can't add to pointers together.
The function with the problem is TS_function on the ShellExecute statement line.

What I would like to have happen is my client.exe application launch taking in a base value 1 or a -1, and a pair based value of 1 through 15.

thank you for any help.

cheers.

#include "fxAuto.h"

BOOL APIENTRY _DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

int _stdcall TS_function(int _position, int pair )
{

int MyAvg = _position + 1;
HINSTANCE HINSsd =
ShellExecute(NULL,"open","C:\\client.exe" + " " +
_position + " " + pair , NULL, NULL, SW_SHOWNORMAL);
//execute it.


return( MyAvg ) ;
}
 
I'm sorry to repost on this. i'm at a loss i really need some help on this. I have a vb.net application that is able to be launched from a command line window. this application takes in 2 input values from the calling program. i have tested it from the command line window and the application works so i know that this is not the problem.
an example on how to launch this application would be
c> client.exe -1 12 (application must take in two values)

on the c++ side I have tried these solutions thus far and none have worked. :

stringstream strNew;
strNew << "C:\\client.exe " << _position << " " << pair;
HINSTANCE HINSsd = ShellExecute(NULL,"open", strNew.str().c_str(), NULL, NULL, SW_SHOWNORMAL); //execute it.

which nothing happens.

I have tried this.
char* result3 = "C:\\client.exe 1 12";
HINSTANCE HINSsd = ShellExecute(NULL,"open", result3, NULL, NULL, SW_SHOWNORMAL); //execute it

nothing happens
(...but if i do this )
char* result3 = "C:\\client.exe";
HINSTANCE HINSsd = ShellExecute(NULL,"open", result3, NULL, NULL, SW_SHOWNORMAL); //execute it

the program launchs with errors cause the input values are not there.

I have tried this.
stringstream strNew;
stringstream strNew2;
string itoString;
string itoString2;
string result;

strNew << _position;
itoString = strNew.str();

strNew2 << pair;
itoString2 = strNew2.str();

result = "C:\\client.exe " + itoString + " " + itoString2;
HINSTANCE HINSsd = ShellExecute(NULL,"open", result.c_str, NULL, NULL, SW_SHOWNORMAL); //execute it.

nothing happens.

And i have tried this.
string result2;
result2 = "C:\\client.exe ";

if (_position == -1 )
{
result2 = result2 + "-1 ";
}

if (_position == 1 )
{
result2 = result2 + "1 ";
}

if (pair = 1)
{
result2 = result2 + "1";
}
if (pair = 2)
{
result2 = result2 + "2";
}
if (pair = 3)
{
result2 = result2 + "3";
}
if (pair = 4)
{
result2 = result2 + "4";
}
if (pair = 5)
{
result2 = result2 + "5";
}
if (pair = 6)
{
result2 = result2 + "6";
}
if (pair = 7)
{
result2 = result2 + "7";
}
if (pair = 8)
{
result2 = result2 + "8";
}
if (pair = 9)
{
result2 = result2 + "9";
}
if (pair = 10)
{
result2 = result2 + "10";
}
if (pair = 11)
{
result2 = result2 + "11";
}
if (pair = 12)
{
result2 = result2 + "12";
}
if (pair = 13)
{
result2 = result2 + "13";
}
if (pair = 14)
{
result2 = result2 + "14";
}

HINSTANCE HINSsd = ShellExecute(NULL,"open", result2.c_str, NULL, NULL, SW_SHOWNORMAL); //execute it.

nothing happens.

I really need some help on this. The problem is coming in on the args part of the shellexecute statement. if i try any of the above without the args it works.. of course the .net program crashs because it wants the two args but it launchs. but once i add the 2 args nothing happens.

any suggestions? or other ways to go about this problem.

cheers.

thnx you for any help. i know there has to be a way for C++ to pass in args to another application.
 
ok ok ok. i'm dumb. i should of read on the shell first. but for some reason i had it in my mind that the args had to be passed with the app string. boy was i wrong. solution:

char* result3 = "C:\\client.exe";
stringstream strNew;
strNew << _position << " " << pair;

HINSTANCE HINSsd = ShellExecute(NULL,"open", result3, strNew.str().c_str(), NULL , SW_SHOWNORMAL); //execute it.
thank you for the input.
 
> if (pair = 1)
You started off using ==, and you slipped into using =
Make all your comparisons ==

> HINSTANCE HINSsd = ShellExecute(NULL,"open", result2.c_str
You need to invoke the method, not point at the method
Code:
HINSTANCE HINSsd = ShellExecute(NULL,"open", result2.c_str()

PS.
Don't forget the [code][/code] tags when posting code

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top