Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2004

Tip: Looking for answers? Try searching our database.

Invoking an unmanaged exe

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JTnospam@verizon.net - 15 Oct 2004 19:27 GMT
Hi,
I am just beginning to explore this area, so my question may seem ignorant.  
But,
here goes...

I am trying to design a Windows service in VB.NET that would grab a file and
send it over a modem to an electronic bulletin board system.  I have software
(Symantec Procomm Plus) that will do the transmission, and can even handle
scripts.  How do I invoke Procomm Plus with my windows service and pass it my
file?  I have tried creating a RCW from the Procomm DLL's but get an error
message saying that they are not recognized as properly manifested.

Thanks.

JT
Mattias Sj?gren - 16 Oct 2004 20:04 GMT
>How do I invoke Procomm Plus with my windows service and pass it my
>file?

Have you tried System.Diagnostics.Process.Start() ?

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

JTnospam@verizon.net - 18 Oct 2004 17:27 GMT
Thanks Mattias.  I have done some experimenting with this, and can pass in
the args I need for the scripts.  The problem I have with this method is
getting an indication of success or failure of the transmission.  I can
access the exitcode for pw5.exe by listening for .HasExited, but that exit
code only indicates whether the program terminated abnormally or not and does
not give me any indication of the success or failure of my transmission.  

JT

"Mattias Sjögren" wrote:

> >How do I invoke Procomm Plus with my windows service and pass it my
> >file?
>
> Have you tried System.Diagnostics.Process.Start() ?
>
> Mattias
William DePalo [MVP VC++] - 18 Oct 2004 19:09 GMT
> Thanks Mattias.  I have done some experimenting with this, and can pass in
> the args I need for the scripts.  The problem I have with this method is
[quoted text clipped - 3 lines]
> does
> not give me any indication of the success or failure of my transmission.

Check the docs for HasExited and you will find this:

<quote>
If a handle is open to the process, the operating system releases the
process memory when the process has exited, but retains administrative
information about the process, such as the handle, exit code, and exit time.
To get this information, you can use the ExitCode and ExitTime properties.
These properties are populated automatically for processes that were started
by this component. The administrative information is released when all the
Process components that are associated with the system process are destroyed
and hold no more handles to the exited process.
</quote>

Regards,
Will
JTnospam@verizon.net - 18 Oct 2004 20:01 GMT
Thanks William,

I have read the documentation, but I am not sure what to do with it to get
the return value I seek.  My code is as follows;

Private Function TransmitFiles(ByVal strScriptArgs As String) As Integer

 Try

     If strScriptArgs.Length > 0 Then

    Dim myProcomm As New Process

    With myProcomm.StartInfo
      .FileName = "pw5.exe"
      .Arguments = strScriptArgs
      .WindowStyle = ProcessWindowStyle.Hidden

    End With

               With myProcomm

     If .Start() Then

        If .HasExited Then

            Return .ExitCode

        End If

     Else
        Return 1                                      'Failed to start
     End If

    End With

      End If

      Catch ex As System.ComponentModel.Win32Exception
    If ex.NativeErrorCode = 2 Then            'File Not Found Error
        Return 2
    ElseIf ex.NativeErrorCode = 5 Then            'Access Denied Error

        Return 5
    End If

   End Try

End Function

JT

> > Thanks Mattias.  I have done some experimenting with this, and can pass in
> > the args I need for the scripts.  The problem I have with this method is
[quoted text clipped - 19 lines]
> Regards,
> Will
William DePalo [MVP VC++] - 18 Oct 2004 20:04 GMT
> Thanks William,

You are welcome.

> I have read the documentation, but I am not sure what to do with it to get
> the return value I seek.  My code is as follows;

If the process you start returns a return code then ExitCode should pick it
up. Many processes simply return 0.

Regards,
Will

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.