留个记录


以后可能用得着的几个 api 函数,留个记录,以免到要用时忘了名称。

IsUserAnAdmin - 判断当前用户是否是 Administrators 组的成员:

  declare long IsUserAnAdmin in shell32
  ? iif( 1 == IsUserAnAdmin(), 'Yes', 'No')

FindExecutable - 查找打开指定文件的缺省关联程序:

  ? GetExecFile('rar')
  function GetExecFile( tcExtName )       && tcExtName - 要检测的文件扩展名
    local lcFile, lcBuff, lnResult, lcRet
    declare long FindExecutable in shell32 string lpFile, string lpDirectory, string @ lpResult
    m.lcFile = forceext(sys(2015), m.tcExtName)
    strtofile([], m.lcFile)
    m.lcBuff = replicate(chr(0), 260)
    m.lnResult = FindExecutable(justfname(m.lcFile), justpath(m.lcFile), @ m.lcBuff)
    erase (m.lcFile)
    m.lcRet = ''
    do case
    case 31 == m.lnResult
        messagebox('没有缺省关联程序!', 16)
    case 32 <= m.lnResult
        m.lcRet = rtrim(m.lcBuff, chr(0))
    otherwise
        messagebox('其他错误,错误码:' + transform(m.lnResult), 16)
    endcase
    return m.lcRet
  endfunc

DoFileDownload - 调用 IE 自带的下载工具

declare long DoFileDownload in shdocvw.dll string lpszFile
DoFileDownload(strconv('http://www.abc.com/files/file01.rar', 5))

shell32 中未公开的函数(参见 http://vbnet.mvps.org/index.html?code/internet/dofiledownloadcustom.htm):

Ord Hidden name pb Renamed to Operation Performed
         
59 _RestartDialog 12 SHRestartSystemMB Displays the "System Settings Change" reboot message box
60 ? 4 SHShutDownDialog Displays the Shut Down dialog (Start/Shut Down)
61 ? 24 SHRunDialog Displays the Run dialog (Start/Run)
         
62 _PickIconDlg 16 SHChangeIconDialog Allows choosing form amongst a files icons.
         
31 _PathFindExtension 4 SHGetExtension Returns pointer to the last dot in szPath and the string following it.
32 _PathAddBackslash 4 SHAddBackslash Inserts a backslash before the first null char in szPath.
34 _PathFindFileName 4 SHGetFileName Returns a pointer to the string in szPath after the last backslash.
35 _PathRemoveFileSpec 4 SHGetPath Returns a pointer to the string in szPath before the last backslash.
40 _PathIsRelative 4 SHPathIsRelative Returns non-zero if szPath does not evaluate to a UNC path.
43 _PathIsExe 4 SHPathIsExe Returns non-zero if szPath has an executable extension.
45 _PathFileExists 4 SHFileExists Returns non-zero if szPath is valid absolute UNC path.
52 _PathGetArgs 4 SHGetPathArgs Returns a pointer to the string after first space in szPath.
55 _PathQuoteSpaces 4 SHAddPathQuotes Adds quotes if the path or file contains a space
56 _PathUnquoteSpaces 4 SHRemovePathQuotes Removes quotes from quoted paths/filename
92 _PathGetintPath 4 SHGetShortPathName Fills szPath w/ its DOS (8.3) file system string.


下面这些也是比较有用的:
PathBuildRoot - Creates a root path from a given drive number. 
PathCompactPathEx - Truncates a path to fit within a certain number of characters by replacing path components with ellipses. 
PathFileExists - Determines whether a path to a file system object such as a file or directory is valid. 
PathFindExtension - Searches a path for an extension. 
PathFindFileName - Searches a path for a file name. 
PathFindOnPath - Searches for a file. 
PathGetDriveNumber - Searches a path for a drive letter within the range of "A" to "Z" and returns the corresponding drive number. 
PathGetShortPath - Retrieves the short path form of a specified input path.
PathIsDirectory - Verifies that a path is a valid directory. 
PathIsNetworkPath - Determines whether a path string represents a network resource. 
PathIsRelative - Searches a path and determines if it is relative. 
PathIsRoot - Parses a path to determine if it is a directory root. 
PathIsURL - Tests a given string to determine if it conforms to a valid URL format. 
PathMakeUniqueName - Creates a unique path name from a template. 
PathRenameExtension - Replaces the extension of a file name with a new extension. 
PathYetAnotherMakeUniqueName - Creates a unique filename based on an existing filename.
UrlEscape - Converts characters in a URL that might be altered during transport across the Internet ("unsafe" characters) into their corresponding escape sequences. 
UrlGetPart - Accepts a URL string and returns a specified part of that URL. 
UrlHash - Hashes a URL string. 
UrlUnescape - Converts escape sequences back into ordinary characters.

 

参考网站:http://vbnet.mvps.org/index.html

 

GB2312:CHR(160-254) + CHR(160-254)
GBK:CHR(129-254) + CHR(64-126,128-254)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值