1 / 47
文档名称:

PB编程实例【DOC精选】.doc

格式:doc   大小:131KB   页数:47页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

PB编程实例【DOC精选】.doc

上传人:luciferios04 2017/2/22 文件大小:131 KB

下载得到文件列表

PB编程实例【DOC精选】.doc

相关文档

文档介绍

文档介绍:(1) 获得安装的打印机在这个例子中, 我们生成一个以打印机名的下拉框 string printers[] int rtn, i, nbPrinters rtn = RegistryKeys & (\"HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Print\\Printers\", & printers) nbPrinters = UpperBound(printers) FOR i=1 TO nbPrinters (printers[i]) NEXT (2) 获得当前的用户名和机器名在这个应用中, 需要定义下面的两个 API 函数 FUNCTION long puterNameA(ref puterName, ref ulong BufferL ength) LIBRARY \"\" FUNCTION long GetUserNameA(ref string UserName, ref ulong BufferLength) LIBRARY \"\" and then long ll_ret string puterName, ls_UserName ulong BufferLength = 250 // you may need to adjust this. see Note puterName = Space(BufferLength) ls_UserName = Space(BufferLength) ll_ret = puterNameA(puterName, BufferLength) ll_ret = GetuserNameA(ls_UserName, BufferLength) 注意: 通过一些实验, 在使用函数 GetUserNameA 获得用户名时, 如果定义的 BUFFERLE NGTH 小于实际的用户名长度, 函数可能会出现异常. (3) 获得当前的目录首先定义 API 函数 FUNCTION long GetCurrentDirectoryA( long length , ref string path) & LIBRARY \"Kernel32\" 接下来 long ll_ret string ls_path ls_path = Space(250) ll_ret = GetCurrentDirectoryA(250, ls_path) IF ll_ret >0 THEN ls_path = Left(ls_path,ll_ret) MessageBoxBox(\"\", ls_path) ELSE Messagebox(\"Error\",\"Err GetCurrentDirectory \"+ String(ll_ret)) END IF (4) 创建或删除目录首先定义如下 API 函数 FUNCTION boolean CreateDirectoryA(ref string path, long attr) LIBRARY \"\" FUNCTION boolean RemoveDirectoryA( ref string path ) LIBRARY \"\" 接下来 CreateDirectoryA( \"C:\\TempDir\", 0) // always 0 RemoveDirectoryA( \"C:\\TempDir\" ) 注意: 没有办法同时创建两个以上的目录. 可以一个一个的创建. (5) 文件改名使用下面的函数, 把文件\" 移动\" 成一个新的名字( 没有关系, 不会真的移动文件, 只是改名) Simply \"move\" it under a new name with the function FUNCTION BOOLEAN MoveFileA(STRING oldfile, STRING newfile) LIBRARY \"\" (6) 禁止 ODBC 的“ LOGIN ”窗口在 DbParm 中使用如下的连接选项 Use this ConnectOption in your DbParm : =\"ConnectString=\'DSN=mydb;UID=dba;PWD=sql\',\" +& \"ConnectOption=\'SQLDRIVER_CONNECT,SQL_DRIVER_NOPROMPT\'\ " (7) 使应用休眠定义: SUBROUTINE Sleep(Long lMilliSec) LIBRARY