I ran across a great ArcScript that opens an .exe from inside ArcMap, which is exactly what I needed. The example says to create a UI button, drop the code into a module, and then call the subroutine in the OnClick event. POOF! Works like a charm. I'm excited, but I need to get this into a .dll, because I have to deploy it on many, many machines.
I go to vs2005. I create a new Class Library, add the proper references, let the wizard generate the necessary information and so on and so on. Then I add the code, which looks like this:
Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3
Public Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub RunMozillaFirefox()
Dim RetVal As Long
On Error Resume Next
RetVal = ShellExecute(0, "open", "C:\Program Files\Mozilla Firefox\firefox.exe", "www.google.com", _
"", SW_SHOWMAXIMIZED)
End Sub
and call RunMozillaFirefox in the OnClick subroutine.
I go to ArcMap, hit "Tools --> Customize --> Commands
My command is there! Now I'm getting really excited.
I drag the command onto a toolbar, click on it, and... nothing. nada. zero, zip, zilch.
Can anybody tell me why this code works when its placed in a module, but not when its compiled as part of a .dll?
Thanks in advance...
Justin