Win10环境用CreateFile没试成,用OpenFile试试:
注意:测试时文件名是用完整路径
DECLARE LONG OpenFile IN Kernel32 STRING@, STRING@, LONG
DECLARE LONG CloseHandle IN Kernel32 LONG
DECLARE INTEGER ShellExecute IN shell32.DLL INTEGER HWND,;
STRING lpszOP, ;
STRING lpszFile, ;
STRING lpszParams, ;
STRING lpszDir, ;
INTEGER fsshowcmd
DECLARE INTEGER GetDesktopWindow IN win32api
HWND = GetDesktopWindow()
lpszOP = "open"
* 指定要打开的文件名
lpszFile ="C:\TEMP\test.doc"
**lpszFile ="rhtbzy.doc"
lpszParams = ""
lpszDir = lpszFile
fsshowcmd =1
* 执行ShellExecute命令
LNRETURN = ShellExecute(HWND, lpszOP, lpszFile, lpszParams, lpszDir, fsshowcmd)
DO WHILE isFOpen(lpszFile)
INKEY(1)
ENDDO
**INKEY(3)
DO WHILE !isFOpen(lpszFile)
INKEY(1)
ENDDO
? "文件已经关闭"
RETURN
FUNCTION isFOpen(cFileName)
LOCAL hFile, st
st = REPLICATE(0h00,136)
hFile = OpenFile(@cFileName, @st, 0x10)
IF (hFIle != -1)
CloseHandle(hFile)
ENDIF
RETURN hFIle != -1
ENDFUNC