-
C++ application from VB.net
I have a C++ application that I want to start from VB.net
I was able to do that this way:
Dim startInfo As ProcessStartInfo
Dim pStart As New Process
startInfo = New ProcessStartInfo(AppDirectory) 'AppDirectory is the directory of my C++ application
pStart.StartInfo = startInfo
pStart.Start()
pStart.WaitForExit()
the idea behind all this is that i want to do a user interface that takes some input from the user, save them in a text file, the launch the C++ program that reads the information from the text file and do what it is supposed to do.
the problem is that when I do this, the C++ appplication runs, but doesnt read the text file!!
in fact i tried a dummy program, where i just wrote a C++ program that reads from a text file and simply launch it from VB.net and still the C++ program still didnt read from txt file
Any ideas?? :S
(btw, when the C++ is run directly (not through VB.net), it works 100%)
-
Welcome to DevX 
So, what is happening with the code you are running? Is it giving you an error?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Thanks for the welcome.
Back to my issue, I am not having an error. On the contrary.
What i have is a C++ program that runs perfectly alone. this program takes input values from the user and uses them in its own functions.
Now what I want to do is to have a nice visual interface with the user, so what i thought about is to use the VB.net to do the interface, get the input parameters from the user, and save those parameters in a text file. After that, I start the C++ program through the VB.net (as described above). now when I do that, the C++ code works as it should, but unfortunately it does need read the values from the text file (or any other text file!!!!).
its driving me crazy, becoz when i run it alone the C++ code reads from the text file, but when launched through the VB.net, it does not!!
I hope this explained my problem better.. hoping someone has a solution!
-
-
I don't see where you are actually running/executing your .EXE file.
What is the name of your C++ program that you need to run?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
the directory of the C++ is 'AppDirectory' string, that is passed to the 'pStart' process.
i am calling the exe file (of my C++ code) from the running VB.net program
-
Yes, I understand that, but in order to execute the exe, you have to specifiy the exe name, and I don't see that being done.
Example: I have a program called c:\MyProg\Hack.Exe
I'm not going to be able to run it simply by telling VB that the program is in C:\MyProg
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
OH!!
i callit using the 'Start' method: pStart.Start()
this is the code:
pStart.StartInfo = startInfo
pStart.Start()
pStart.WaitForExit()
-
To execute and external program from VB.NET, you do
Code:
System.Diagnostics.Process.Start("c:\myprog\hack.exe")
What is confusing me about what you are doing is that I see no .exe file mentioned anywhere.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
I told u. its stored in the 'AppDirectory' String
in other words, if I want to run ur program, i would do this:
AppDirectory = "c:\myprog\hack.exe"
then, after creating my 'process' object "pStart", i set its 'startInfo' to AppDirectory. then start the process.
it works the same way as ur way.
I am not having a problem starting the C++ executable file, because it runs. My problem is that it has to read from a file, but it doesn't do that when launched from VB.net
(thank u for ur patience )
-
 Originally Posted by Ramiol
My problem is that it has to read from a file, but it doesn't do that when launched from VB.net
And the reason that I was wondering if the program was actually running or not is because this makes no sense.
VB.NET does nothing to the program except execute it. If it works when run by itself, then there is no reason it should not work when run by being shelled.
You say it "doesn't read the text file".....how do you know that? What should the results be if it did read the text file?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
i did a dummy C++ program (to test it) that just reads integers from a text file and prints them out on the console.
when it is run alone it works, but when it is shelled, it prints out random values like: '-858993460' instead of '2' for example
-
Again, that doesn't make any sense, so I'm going to try an replicate it.
Post the code in your C++ dummy program so that I will be using the exact same thing that you are.
Also, what C++ compiler are you using?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
i know it doesn't make any sense!!! thats y im posting my problem 
anyways, this is the C++ code:
#include <iostream>
#include <fstream.h>
//using namespace std;
void main()
{
ifstream fin;
const char* FILE_NAME_I = "try.txt";
const char* FILE_NAME_O = "generated.txt";
fin.open(FILE_NAME_I,ios::in);
if(!fin)
{ cout<<"ERROR in opening file \n";
cin>>a;}
else
{
int Vector_Size,Num_Elem_Vec, Num_of_Reg,Elem_Size;
char* s;
fin>>Vector_Size;
fin>>Num_Elem_Vec;
fin>>Num_of_Reg;
fin>>Elem_Size;
fin.close();
cout<<"Vector Size: "<<Vector_Size<<endl;
cout<<"Number of Elements per Vector: "<<Num_Elem_Vec<<endl;
cout<<"Number of Registers: "<<Num_of_Reg<<endl;
cout<<"Element Size: "<<Elem_Size<<endl;
ofstream fout;
fout.open(FILE_NAME_O,ios: ut);
fout<<"Vector Size: "<<Vector_Size<<endl;
fout<<"Number of Elements per Vector: "<<Num_Elem_Vec<<endl;
fout<<"Number of Registers: "<<Num_of_Reg<<endl;
fout<<"Element Size: "<<Elem_Size<<endl;
fout.close();
}
}
and im using Microsoft Visual C++ 6.0
-
 Originally Posted by Ramiol
im using Microsoft Visual C++ 6.0
I was hoping you would say that, because that is what I have. 
I'm getting a compile error on:
Code:
int Vector_Size,Num_Elem_Vec, Num_of_Reg,Elem_Size;
char* s;
I'm not real good with C - any idea why. I just copied and pasted what you posted directly into a new project and did a build.
Both int and char* are highlighted
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Similar Threads
-
By sathya_k_83 in forum .NET
Replies: 12
Last Post: 03-09-2010, 09:51 AM
-
By m.sherling in forum .NET
Replies: 1
Last Post: 11-15-2006, 10:08 AM
-
By krishna in forum VB Classic
Replies: 0
Last Post: 11-25-2002, 11:09 PM
-
Replies: 1
Last Post: 09-18-2002, 01:15 PM
-
By Neil McKay in forum .NET
Replies: 2
Last Post: 02-28-2002, 12:01 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks