|
Hello Everybody,
I hope i have choosen the right forum for my Question.
I have a little application which starts another programm with a specific path (a txt-file).
Yes, easy and simple, it works fine with ShellExecute, but i have a problem with some Executables(I have to test a few programs). One Executable opens correct but it don´t opens the given path. I don´t understake whats wrong, because if I drag and drop the txt-file manualy on the executable it works.
So my Question is, are ShellExecute and Drag&Drop two different things to open a programm? Does anybody know a way to fix my problem ?
Thanks in advance,
Michael
|
|
|
|
|
You need to show the section of the code that tries to start the program and explain exactly what part of it is not working.
|
|
|
|
|
void StartEXE (String^ path)
{
TCHAR prog[] = TEXT("C:\\...\\....");
string p ;
MarshalString(path, p);
std::string str= p;
TCHAR *param=new TCHAR[str.size()+1];
param[str.size()]=0;
const TCHAR open[] = TEXT("runas")
ShellExecute( NULL, open, prog, param, NULL, SW_SHOWNORMAL );
}
void MarshalString ( String ^ s, string& os )
{
using namespace Runtime::InteropServices;
const char* chars =
(const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
}
This is the code i use. I call StartEXE with a String like C:\\test.txt , the programmpath is fix in the code.
The Programm i want to open opens but it don´t open the path.
This happens only by one Programm, if i want to open another programm this code works.
Any Ideas?
|
|
|
|
|
Without seeing the actual parameters and the code of the executing program it's impossible to guess what may be happening. It would probably be a good idea to add some debug code to the called program so you can see exactly what parameters it is trying to deal with. What is the "runas" parameter supposed to do?
|
|
|
|
|
You might also want to consider asking for help here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
That should only work if the application you want to start supports command line parameters, or if it the default application for starting the document type you're trying to open.
|
|
|
|
|
Thats what i wanted to hear
The "runas" is to start a exe with admin rights.
Is it right that open a Programm with ShellExecute is different to Drag&Drop way ? Because if i drag and drop a textfile on the Program i want to open it works. btw the program is a finished one done not by myself.
Is there a way to drag&drop the textfile to the program via code?
|
|
|
|
|
Starting a program by command line and drag&drop are different things. An application can implement any (or neither). You cannot simulate drag&drop from code if that application is not handling the drop.
|
|
|
|
|
Thank you for the answer.
The Application i want to open supports drag&drop.
How can i implement the drag&drop function in my program?
Do you have any Ideas ?
|
|
|
|
|
Not exactly sure what may be causing your problem... but the unix/linux calls (also supported by Windows) usually work pretty well for me.
Try them out (required header is in documentation)...
spawn[^]
exec[^]
|
|
|
|