运行以下PRG创建SHORTCUT总报错,请教原因?
运行以下PRG总报错,请教原因?
*********************************************************
* CREATE DESKTOP SHORTCUT
*********************************************************
*
* Demonstrates using shell api fCreateShellLink
* to create a shortcut to a file on the Windows desktop.
*
*********************************************************
*~ Main program variables. These are the only ones that need to be changed:
*~ lcExeName: This is the actual file name (without any path) of the .EXE to create a shortcut to.
*~ lcAppName: This is the name of the application (like "Microsoft Visual FoxPro").
lcExeName = "dianhuafei.EXE"
lcAppName = "电话费管理"
*~ #DEFINEs from FOXPRO.h (HOME() + 'foxpro.h')
#DEFINE MB_YESNO 4 && Yes and No buttons
#DEFINE MB_ICONQUESTION 32 && Warning query
#DEFINE CR CHR(13) && Carriage Return
#DEFINE ERROR_SUCCESS 0 && Success error code from WINERROR.H
#DEFINE FORMAT_MESSAGE_FROM_SYSTEM 0x00001000 && Value for use with FormatMessage API. From WINBASE.H
*~ Declare the function in the VB DLL
DECLARE INTEGER fCreateShellLink IN vb6stkit.DLL ;
STRING lpstrFolderName, ;
STRING lpstrLinkName, ;
STRING lpstrLinkPath, ;
STRING lpstrLinkArguments, ;
INTEGER fPrivate, ;
STRING sParent
*~ Declare function to return system error code if the call fails.
DECLARE INTEGER GetLastError IN win32api
*~ Declare function to return text message from system error code.
DECLARE INTEGER FormatMessage IN kernel32.DLL ;
INTEGER dwFlags, ;
STRING @lpSource, ;
INTEGER dwMessageId, ;
INTEGER dwLanguageId, ;
STRING @lpBuffer, ;
INTEGER nSize, ;
INTEGER Arguments
*~ Set up variables. These variables remain unchanged.
strLinkPath = JUSTPATH(SYS(16,0)) + "\" + lcExeName + CHR(0)
strLinkName = "Shortcut to " + ALLT(lcAppName)
strLinkArguments = "" + CHR(0)
fPrivate = -1
strGroupName = "..\..\Desktop"
sParent = "$(Programs)"
*~ Ask the user if they would like the shortcut created.
lnAns = MESSAGEBOX("Would you like a shortcut to " + lcAppName + " on your Desktop?", ;
MB_YESNO+MB_ICONQUESTION,"Setup")
IF lnAns = 6 && User answered YES.
lnSuccess = fCreateShellLink(strGroupName, ;
strLinkName, ;
strLinkPath, ;
strLinkArguments, ;
fPrivate, ;
sParent)
IF !(lnSuccess > ERROR_SUCCESS)
*~ If the process failed for some reason, we put up a messagebox saying so
*~ and display the system error code from WINERROR.H. We also extend this
*~ by using FormatMessage API to display a character error message.
lpBuffer = SPACE(128)
lnError = GetLastError()
=FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ;
'WINERROR.H', lnError, 0, @lpBuffer, 128 , 0)
=MESSAGEBOX("Unable to create desktop shortcut." + CR + ;
"System Error code: " + ALLTRIM(STR(lnError)) + CR + ;
"System Error message: "+ALLT(lpBuffer),64,"ERROR")
ENDIF
ENDIF