vb6 - Load shortcut then close form automatically -
i want achieve when shortcut link runs ... form closes automatically, btw im new vb coding appreciated, here's code far
private sub form_load() set ss = createobject("wscript.shell") ss.run chr(34) & ss.specialfolders("desktop") & "\app\somegame.lnk" & chr(34) end sub
assuming you're using vb6 (which code looks like) can close form calling
unload me
at end of form_load
event handler.
however, don't need use form launch shortcut - can add module project (right-click project, select add
-> module
) , call shellexecute()
function launch shortcut so:
'declare shellexecute() api function private declare function shellexecute lib "shell32.dll" alias "shellexecutea" _ (byval hwnd long, byval lpoperation string, byval lpfile string, _ byval lpparameters string, byval lpdirectory string, _ byval nshowcmd long) long private const sw_shownormal long = 1 'entry point of program public sub main() dim spath string spath = "c:\app\somegame.lnk" shellexecute 0, vbnullstring, spath, vbnullstring, "c:\", sw_shownormal end sub
to make work, set startup object
under project properties sub main
.
using approach, don't have form - program runs command-line (or own shortcut). it's better not create / show form if program doesn't need since forms use resources.
with said, should try using vb.net or c# write programs windows - vb6 old technology without support , can't handle number of new technologies. if don't know vb6 there's little point in learning - time put better use learning vb.net / c#.
Comments
Post a Comment