While I was fighting with Vista's restrictions of creating shortcut to start the program upon bootup I found this and translated to PB.
Since I have no access to Vista I would appreciate feedbacks how this code works there. I want to know especially that if creation of the shortcut needs administrator privileges or not, if any popup window asks for user's permission and if the shortcut is created for All Users indeed the program will run for any user without asking for permission.
Discussion here: http://www.powerbasic.com/support/pb...ad.php?t=37447
Peter Redei
Since I have no access to Vista I would appreciate feedbacks how this code works there. I want to know especially that if creation of the shortcut needs administrator privileges or not, if any popup window asks for user's permission and if the shortcut is created for All Users indeed the program will run for any user without asking for permission.
Discussion here: http://www.powerbasic.com/support/pb...ad.php?t=37447
Code:
#COMPILE EXE #INCLUDE "win32api.inc" FUNCTION WithSlash(a$) AS STRING IF LEN(a$) > 0 THEN IF RIGHT$(a$, 1) <> "\" THEN WithSlash = a$ + "\" ELSE WithSlash = a$ END IF END IF END FUNCTION FUNCTION GetDestinationFolder(lngLocation AS LONG) AS STRING DIM lpidlStartUp AS LONG DIM lResult AS LONG DIM szPathStartUp AS ASCIIZ * %MAX_PATH lResult = SHGetSpecialFolderLocation(%NULL, lngLocation, lpidlStartUp) IF ISFALSE lResult THEN lResult = SHGetPathFromIDList(BYVAL lpidlStartUp, szPathStartUp) FUNCTION = szPathStartUp END IF END FUNCTION FUNCTION CreateShortcut(sExecutableFileName AS ASCIIZ, sShortcutName AS ASCIIZ) AS LONG LOCAL Res AS LONG Res = %TRUE IF DIR$(sExecutableFileName) = "" THEN MSGBOX "Can`t find executable file!" EXIT FUNCTION END IF Res = WritePrivateProfileString("InternetShortcut", "URL", sExecutableFileName, sShortcutName) Res = Res AND WritePrivateProfileString("InternetShortcut", "IconIndex", "0", sShortcutName) Res = Res AND WritePrivateProfileString("InternetShortcut", "IconFile", sExecutableFileName, sShortcutName) FUNCTION = Res END FUNCTION FUNCTION PBMAIN() 'change the values as needed CreateShortcut "C:\Property Auction Ticker\Property Auction Ticker.exe", WithSlash(GetDestinationFolder(%CSIDL_COMMON_STARTUP)) & "Property Auction Ticker.url" END FUNCTION