| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1099 人关注过本帖
标题:谁有测试软盘和打印机是否准备好的代码?
只看楼主 加入收藏
pjq49
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2005-4-4
收藏
 问题点数:0 回复次数:5 
谁有测试软盘和打印机是否准备好的代码?
那位大虾帮帮忙::
     谁有测试软盘和打印机是否准备好的代码?
      或者谁知道哪儿有下载!最近小弟开发一个软件遇到点问题!!!
谢谢了!
搜索更多相关主题的帖子: 打印机 软盘 代码 软件 
2005-07-12 09:34
tzhtang
Rank: 1
等 级:新手上路
帖 子:888
专家分:0
注 册:2004-8-30
收藏
得分:0 
IsDiskInDrive 判断软盘驱动器中是否插有软盘

在需要向软盘复制/读取数据的程序中,在复制/读取数据前判断软盘驱动器中是否插有软盘是总要的,该函数可用于判断软盘驱动器中是否插有软盘。

定义方式:

Declare integer IsDiskInDrive IN "MyDll.dll" String

调用方式:

If IsDiskInDrive("A:\") = 0

? "驱动器 A: 中没有插盘"

Else

? "驱动器 A: 中插了盘"

Endif


2005-07-12 16:00
tzhtang
Rank: 1
等 级:新手上路
帖 子:888
专家分:0
注 册:2004-8-30
收藏
得分:0 
你从编程论坛中找一个文件就可以了(mydll.dll)

2005-07-12 16:18
pjq49
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2005-4-4
收藏
得分:0 
请问斑竹,测试打印机的呢?
能告诉我吗?

2005-07-13 08:06
tzhtang
Rank: 1
等 级:新手上路
帖 子:888
专家分:0
注 册:2004-8-30
收藏
得分:0 

*!* 先通过SET(‘PRINTER’,2)等方法获取名称(如:BJC-255SP),然后再通过注册表获取相关信息。如下: *!* [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\BJC-255SP] *!* "ChangeID"=dword:024f329e *!* "Status"=dword:00000180 *!* "Name"="BJC-255SP" *!* "Share Name"="" *!* "Print Processor"="WinPrint" *!* "Datatype"="RAW" *!* "Parameters"="" *!* "ObjectGUID"="" *!* "DsKeyUpdate"=dword:00000003 *!* "Description"="" *!* "Printer Driver"="Canon Bubble-Jet BJC-255SP" * 或者直接写10进制数:

#DEFINE HKEY_CLASSES_ROOT 2147483648 && 0x80000000,或用负数: -2147483648 #DEFINE HKEY_CURRENT_USER 2147483649 && 0x80000001,-2147483647 #DEFINE HKEY_LOCAL_MACHINE 2147483650 && 0x80000002,-2147483646 #DEFINE HKEY_USERS 2147483651 && 0x80000003,-2147483645 #DEFINE HKEY_PERFORMANCE_DATA 2147483652 && 0x80000004,-2147483644 #DEFINE HKEY_CURRENT_CONFIG 2147483653 && 0x80000005,-2147483643 #DEFINE HKEY_DYN_DATA 2147483654 && 0x80000006,-2147483642

* 键值的数据类型:1-字符串,3-二进制,4-整数 #DEFINE REG_NONE 0 && Undefined Type #DEFINE REG_SZ 1 && 0~多个字节, 以一个null字符结尾的字符串 #DEFINE REG_EXPAND_SZ 2 && 0~多个字节, 以一个null字符结尾的字符串 && 包含 OS 环境变量 #DEFINE REG_BINARY 3 && 0~多个字节, 可以包含任何数据的二进制 #DEFINE REG_DWORD 4 && 4字节 DWORD值 #DEFINE REG_DWORD_BIG_ENDIAN 5 && 4字节 一个DWORD值的逆序存储形式 #DEFINE REG_MULTI_SZ 7 && 0~多个字节, 以null字符分隔的字符串集合, && 集合中的最后一个字符串以两个null字符结尾 lsPrinterName=SET("Printer" ,2) LOCAL nKey, cSubKey, cEntry, cvalueRead nKey =HKEY_LOCAL_MACHINE cSubKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\&lsPrinterName." cEntry = "Printer Driver" cvalueRead = ReadREG_SZ(nKey, cSubKey, cEntry) IF (EMPTY(cvalueRead)) THEN =MESSAGEBOX("从注册表读打印机 [&lsPrinterName.] 驱动信息失败.") ELSE =MESSAGEBOX("从注册表读打印机 [&lsPrinterName.] 驱动信息是: '" + cvalueRead + "'") ENDIF RETURN

*====================================================================== FUNCTION ReadREG_SZ * 读注册表字符串值(REG_SZ 或 REG_EXPAND_SZ)

* This function reads a REG_SZ value from the registry. * If successful, it will return the value read. * If not successful, it will return an empty string. LPARAMETERS tnHKey, tcSubKey, tcEntry * tnHKey The root key to open. It can be any of the constants defined below. * #DEFINE HKEY_CLASSES_ROOT -2147483648 * #DEFINE HKEY_CURRENT_USER -2147483647 * #DEFINE HKEY_LOCAL_MACHINE -2147483646 * #DEFINE HKEY_USERS -2147483645 * tcSubKey The SubKey to open. * tcEntry The value that is going to be read.

* WIN 32 API functions that are used DECLARE Integer RegOpenKey IN ADVAPI32.DLL ; Integer nHKey, String @cSubKey, Integer @nResult

*!* DECLARE Integer RegQueryvalueEx IN ADVAPI32.DLL ; *!* Integer nHKey, String lpszvalueName, Integer dwReserved,; *!* Integer @lpdwType,string @lpbData, Integer @lpcbData Declare Integer RegQueryvalueEx IN ADVAPI32.DLL ; Integer nKey, ; String cvalueName, ; Integer nReserved, ; Integer @nType, ; String @cBuffer, ; Integer @nBufferSize

DECLARE Integer RegCloseKey IN ADVAPI32.DLL ; Integer nHKey

* Local variables used LOCAL nErrCode && Error Code returned from Registry functions LOCAL nKeyHandle && Handle to Key that is opened in the Registry LOCAL lpdwvalueType && Type of value that we are looking for LOCAL lpbvalue && The data stored in the value LOCAL lpcbvalueSize && Size of the variable LOCAL lpdwReserved && Reserved Must be 0

tnHKey = IIF(TYPE("tnHKey") = "N", tnHKey, HKEY_LOCAL_MACHINE)

* Initialize the variables nKeyHandle = 0 lpdwReserved = 0 lpdwvalueType = REG_SZ lpbvalue = ""

nErrCode = RegOpenKey(tnHKey, tcSubKey, @nKeyHandle) * If the error code isn't 0, then the key doesn't exist or can't be opened. IF (nErrCode # 0) THEN RETURN "" ENDIF

lpcbvalueSize = 1 * Get the size of the data in the value nErrCode = RegQueryvalueEx(nKeyHandle, tcEntry, lpdwReserved, ; @lpdwvalueType, @lpbvalue, @lpcbvalueSize)

* Make the buffer big enough lpbvalue = SPACE(lpcbvalueSize) nErrCode = RegQueryvalueEx(nKeyHandle, tcEntry, lpdwReserved, ; @lpdwvalueType, @lpbvalue, @lpcbvalueSize)

= RegCloseKey(nKeyHandle) IF (nErrCode # 0) THEN RETURN "" ENDIF

lpbvalue = LEFT(lpbvalue, lpcbvalueSize - 1) RETURN lpbvalue


2005-07-18 11:27
fown
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:58
帖 子:1229
专家分:171
注 册:2005-5-26
收藏
得分:0 
以下是引用tzhtang在2005-7-12 16:18:22的发言: 你从编程论坛中找一个文件就可以了(mydll.dll)
这个好像是RMH大侠的作品吧,下次请说明作者,以免引起纠纷

有人说VFP不行了,我想说,你连VFP十分之一的功能都不会用,你怎么知道VFP不行?本人拒绝回答学生的问题我回答问题一般情况下只提供思路不提供代码,请理解
2005-07-22 23:52
快速回复:谁有测试软盘和打印机是否准备好的代码?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016882 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved