Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Win32Exception was Unhandled......

Posted on 2007-03-23
5
Medium Priority
?
1,548 Views
Last Modified: 2009-07-29
Hello Experts,

I have develop a small vb.net app for decompilation of chm's....but i am stuck at getting error as Win32Exception was unhandled.

Can you please help me to get rid of this, where i am wrong?

Please find below code for the same...

Imports System
Imports System.IO
Imports System.Data
Imports System.Security.AccessControl
Imports System.Diagnostics
Public Class Form1
    Private mstrFolderCHMFiles As String = ""
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim foldername As String
        If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            foldername = FolderBrowserDialog1.SelectedPath()
        Else
            Dim Results As DialogResult = FolderBrowserDialog1.ShowDialog
            If Results = Windows.Forms.DialogResult.Cancel Then
                Return
            End If
            Exit Sub
        End If
        mstrFolderCHMFiles = FolderBrowserDialog1.SelectedPath()
        txtinput.Text = foldername
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Application.Exit()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim filename As String
        Dim mydir As New DirectoryInfo(mstrFolderCHMFiles)
        Dim f As FileInfo() = mydir.GetFiles("*.chm")
        Dim i As Integer
        For i = 0 To f.Length - 1
            filename = f(i).FullName
            'Create folder based on filename
            Dim sDir As String = f(i).DirectoryName & "\" & f(i).Name.Replace(f(i).Extension, "")
            If Not (Directory.Exists(sDir)) Then
                Directory.CreateDirectory(sDir)
                Dim startinfo As New ProcessStartInfo
                Dim p As New Process
                startinfo.WindowStyle = ProcessWindowStyle.Normal
                startinfo.ErrorDialog = False
                startinfo.FileName = "C:\WINDOWS\hh.exe -decompile " + sDir + "   " + filename
                'startinfo.Arguments = "-decompile"
                'startinfo.Arguments = sDir
                'startinfo.Arguments = filename
                startinfo.UseShellExecute = False
                Process.Start(startinfo)                                ''''''getting error at this location...
            End If
        Next
        MsgBox("Decompilation Done!!")
    End Sub
End Class


Thanks,
Shailesh
0
Comment
Question by:ShaileshShinde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 18778299
Hi ShaileshShinde,

Try catching the error. Like this....

        Try
            Process.Start(startinfo)
        Catch Win32ex As System.ComponentModel.Win32Exception
            MsgBox(Win32ex.Message)
        End Try

Regards,

Wayne
0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 18778356
Hello Expert,


By adding above lines of code it shows an message as ...

The filename, directory name, or volume label syntax is incorrect..

Can you please help where the changes required..

Thanks,
Shailesh
0
 
LVL 2

Accepted Solution

by:
_Eyeball_ earned 750 total points
ID: 18778377
mhm... try it this way:

startinfo.FileName = "C:\WINDOWS\hh.exe"
startinfo.Arguments = "-decompile " + sDir + "   " + filename

I think your problem may be that you mixed up filename and arguments!

Hope this helps!

Best regards
0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 18778445
Hello Expert,

This works now!!! Thanks a lot!!!

One more query related to this..

If i de-compile more than 5 chm's files... the process atr background is still running..where as i got the msg as decompilation done....

what was the cause of this...or any other way of doing this..

Thanks,
Shailesh
0
 
LVL 2

Expert Comment

by:_Eyeball_
ID: 18778463
Mhm i would guess that (becouse of Process is working assynchrone) that you're simply starting processes faster than they can worked! Do the background processes close after a while?

best regards
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question