views:

60

answers:

1

Hi, I'm using this code to load multiple files using windows context menu, but the problem is that the aplication is open many times as files the user has selected.

For example: If I select 14 files, an open them with the application, the aplicacion is opened 14 times and load the form only one.

But there is a way to send all arguments once? Because %1 send only one file, or there is for example a %2 that send all file pats in one argument? If there is I'vent found.

This my actual code:

Public Class Program

Public Shared Sub Main()

    Dim FurBase As New Core.clsDatabase

    FurBase.Directory = My.Application.Info.DirectoryPath

    Dim returnValue As String()

    returnValue = Environment.GetCommandLineArgs()
    If returnValue.Length > 1 Then

        FurBase.AddTemporalFilepath(returnValue(1).ToString)

    End If

    If Not Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length > 1 Then
        ShowUploader()
    End If

End Sub

Private Shared Sub ShowUploader()
    Dim Uploader As New frmUploader
    Application.EnableVisualStyles()
    Application.Run(Uploader)
End Sub

End Class

Please tell me what think about the code and if ther is any way to improve it.

Regards~

A: 

I was reading about that today; seems you'll need to deal with a DDE server.

There are an old question which can help you: What is the best .net alternative to dde for file associations?

Rubens Farias
Yes, I'm using that. But the command execute the applicacion for each file.The best should be send a big argument with al files and chunk them instead execute app and open file for each file.For example: "C:\app.exe file1.txt file2.txt file3.txt"
Sein Kraft
As I understood, you program will fire _n_ times, but, through DDE or IPC, you'll notify first one to add more files
Rubens Farias
Yep, thats right.
Sein Kraft