Write a VBProgramTo integrate the original programs of VB and VC. Is to use shell functions. The results show that the VC program can be properly displayed, but the VB program is minimized when it is written. I checked the following carefully:ArticleThe default display mode of the original shell function is windowstyle, which is equal to vbminimizedfocus. Then add a vbnormalfocus directly. Everything is OK!
Usage of Shell functions in VB:
Function: Execute an executable file and return a variant (double). If it succeeds, it indicates the task ID of the program. If it fails, it returns 0.
Syntax: Shell (pathname [, windowstyle])
The syntax of the shell function contains the following naming parameters:
Required pathname parameters. Variant (string), the name of the program to be executed, and any required parameters or command line variables, may also include directories or folders, and drives.
Optional. Variant (integer) indicates the window style when the program is running. If windowstyle is omitted, the program runs in a minimized window with focus.
ShellExecute Function:
Its usage is complicated, but its functions are more powerful.
Hinstance ShellExecute (
Hwnd, 'parent window handle
Lpctstr lpoperation, 'Operation or open method "edit", "lead E", "open", "find", "print", "null"
Lptstr lpfile, 'file name. The preceding path can be added.
Lptstr lpparameters, 'Parameter
Lpctstr lpdirectory, 'default folder
Int nshowcmd' Display Mode
);
The function of ShellExecute is to run an external program.
(Or open a registered file, open a directory, print a file, etc ),
And control the external program. Shell functions are relatively weak in this aspect,
In most cases, ShellExecute is more used,
LR = ShellExecute (Me. hwnd, "open", sfile, "", "", vbnormalfocus)
If (LR <0) or (LR> 32) then
'Success
Else
Msgbox "cannot open '" & sfile & "'", vbinformation
End if
Appendix:
This function can also be used to connect to a webpage. Just write it as follows:
ShellExecute 0 &, vbnullstring, "http://coolbasic.yeah.net", vbnullstring, vbnullstring, vbnormalfocus
Or write it like this to send an email:
ShellExecute me. hwnd, "open", "mailto: vbcode@vbcode.com", vbnullstring, vbnullstring, sw_show
In addition, the alternative use of ShellExecute is simpler and more practical. You can use a shell without using APIs!
Connect to the webpage:
Shell "rundll32.exe URL. dll, fileprotocolhandler http://www.online.sh.cn"
Open the file:
Shell "rundll32.exe URL. dll, fileprotocolhandler" & App. Path & "shelltst. txt"