msali
asked on
Executing .lnk, .pif, .exe, .com etc from vb5/win32
Hi,
I have in my file listbox the items form desktop. Now when is select any application i want to execute - Desktop may contain shortcuts, actual files or associated files.
How do i get the shortcuts file to run (.lnk)
thanks
I have in my file listbox the items form desktop. Now when is select any application i want to execute - Desktop may contain shortcuts, actual files or associated files.
How do i get the shortcuts file to run (.lnk)
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi, msali,
The method worked in my machine. I have a DUN entry in start menu folder and a shortcut to "My Documents" in directory C:\. And it worked for this two entry.
Do you specify the filename with extension .lnk?
Let see whether we do the same thing. I make a shortcut to My Documents under root directory C: called "My Documents.lnk". Then I execute it with:
lstrFolder = "C:\My Documents.lnk"
call ShellExecute(0, vbNullString, lstrFolder, "", "", 1)
Could you try it? Thanx.
The method worked in my machine. I have a DUN entry in start menu folder and a shortcut to "My Documents" in directory C:\. And it worked for this two entry.
Do you specify the filename with extension .lnk?
Let see whether we do the same thing. I make a shortcut to My Documents under root directory C: called "My Documents.lnk". Then I execute it with:
lstrFolder = "C:\My Documents.lnk"
call ShellExecute(0, vbNullString, lstrFolder, "", "", 1)
Could you try it? Thanx.
ShellExecute will run any file by finding the program associated with it and executing it. hwnd is the window handle of your main window. lpOperation in this case will be "open". lpFile is the path and filename. lpParameters are any command line paramenters you need. lpDirectory is the directory that your program will run in. nShowCmd is how the window will show. SW_SHOW will show the window normal. SW_HIDE will hide the window. SW_SHOWDEFAULT will show it in its default manner. These and others are listed in the Win32API.txt