运行以下PRG创建SHORTCUT总报错,请教原因?

zhouwy 2003-08-19 08:44:41
运行以下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
...全文
57 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,722

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧