Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21226

Using ShellExecute in VB 6.0

$
0
0
I'm trying to learn how to use this API function.
The code I have is:

'In Module:
Declare Function Shellexecute% Lib "shell.dll" _
(ByVal hwnd%, ByVal lpsz0p$, ByVal lpszFile$, ByVal spszParam$, ByVal lpszDir$, ByVal fsShowcmd%)
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Global Const SW_SHOWNORMAL = 1

'and attached to form1:

Private Sub cmdGo_Click()
Dim hwnd As Double, flag As Double

hwnd = GetForegroundWindow()

flag = Shellexecute(hwnd, "open", "C:\declaration.txt", "", _
"C:\", SW_SHOWNORMAL)

End Sub

I'm getting an error 6 overflow. the file C:\declaration.txt exists.

What am I doing wrong here? I was expecting the file to be displayed in a window.

Viewing all articles
Browse latest Browse all 21226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>