|
-
Jun 15th, 2004, 05:09 PM
#1
Thread Starter
Lively Member
VB.NET application return value...
I have a complicated database configuration tool in VB.NET. It is being called from an NT service (coded in C++). I need to know how to pass back from VB.NET to C++ whether or not my VB.NET app finished with no errors.
In C I would simply do return 0 or return 1, quite simple. But how can you "return" a value in a VB.NET exe?
Here's how I'm calling it from C++, just so you know...
BOOL bRetVal= CreateProcess( NULL, // pointer to name of executable module
(char *) szCmdLine, // pointer to command line string
NULL, // pointer to process security attributes
NULL, // pointer to thread security attributes
TRUE, // handle inheritance flag
CREATE_NEW_CONSOLE | IDLE_PRIORITY_CLASS, // creation flags
NULL, // pointer to new environment block
szWorkingDir, // pointer to current directory name
&StartupInfo, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
);
//
// If the function fails, the return value is zero
//
if ( bRetVal == 0 )
{
CString strMsg;
strMsg.Format( _T("Unable to Create process: %s"), szCmdLine );
LogError( strMsg );
return FALSE;
}
dwRetVal = WaitForSingleObject( pi.hProcess, WaitTime );
switch ( dwRetVal )
{
... down here I handle the cases based on dwRetVal. So basically my question involves getting a VB app to return different values when the API "WaitForSingleObject" is used on the process.
Thanks,
Jacob438
-
Jun 16th, 2004, 08:30 AM
#2
Frenzied Member
You could setup .NET Remoting so they can talk to each other and then you can send any data back and forth that you want quite easily.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 16th, 2004, 11:22 AM
#3
Thread Starter
Lively Member
The problem is my C++ app is not a .NET assembly, it's regular C++, I just use VS.NET for the IDE. My other project is VB.NET.
Isn't there some way to do something like:
App.Quit -1
That way -1 is returned, or whatever value i want to return?
I'm tempted to resort to writing in the registry as to whether or not the app completed successfully because I can't seem to find anything.
Hopefully somebody here is smarter than I am and can help me figure this out.
Thanks,
Jacob438
-
Jun 16th, 2004, 11:35 AM
#4
yay gay
Environment.Exit(0) or Environment.Exit(1)
OR
You could make you Main return a integer and then just return a number
\m/  \m/
-
Jun 16th, 2004, 11:43 AM
#5
Thread Starter
Lively Member
awesome, that's exactly what I was looking for!
Thanks a million PT Exorcist! I've been going crazy looking for that Enviroment.Exit thing.
Here's a few questions:
In vb a sub can't return a value, so how can I have Sub Main return an int? Do I need to have it be a function?
Is Environment.Exit a good way to terminate an application? Does it function similar to End Sub (in Main) except that it returns a value?
Thanks,
Jacob438
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
|
Click Here to Expand Forum to Full Width
|