数学建模社区-数学中国

标题: 老大,怎麼寫并行口呢?用到哪些API函數阿 [打印本页]

作者: kenneth    时间: 2004-6-1 14:39
标题: 老大,怎麼寫并行口呢?用到哪些API函數阿

原來都寫串口的,現在要我寫并行口還有USB口

2 _( V4 A& I. Q7 `: O

我暈,看來這回死定了

( S/ M) J5 l% D( k! D( c2 o. r

我連并口用到哪些API函數都不知道

3 ]3 W u( U E# K1 w7 j

老大救命哦

[em06]
作者: kenneth    时间: 2004-6-1 14:40
而且書上都找不到哦
作者: ilikenba    时间: 2004-6-1 23:28

API之打印函数:, |7 ~: f L9 i; q AbortDoc 取消一份文档的打印 $ Q" B. f) j% d( GAbortPrinter 删除与一台打印机关联在一起的缓冲文件 ' v# U0 b6 T( ]5 v) nAddForm 为打印机的表单列表添加一个新表单 6 K. F) n& Z' I. W. ]AddJob 用于获取一个有效的路径名,以便用它为作业创建一个后台打印文件。它也会为作业分配一个作业编号 7 ~0 ?8 P5 k/ L* L2 q3 C( XAddMonitor 为系统添加一个打印机监视器 ) o$ Y7 H: E. ?$ M6 IAddPort 启动“添加端口”对话框,允许用户在系统可用端口列表中加入一个新端口 $ A' D& k" ~& i0 K AddPrinter 在系统中添加一台新打印机 ! i$ l( {7 B8 Y1 @4 n; {+ s6 O AddPrinterConnection 连接指定的打印机 ' V; y3 I0 O, F# ~# G# o* CAddPrinterDriver 为指定的系统添加一个打印驱动程序 5 w$ O$ B$ G: p2 F' LAddPrintProcessor 为指定的系统添加一个打印处理器 5 Y- {& ^, x: Q4 |6 f; H6 N% R vAddPrintProvidor 为系统添加一个打印供应商 ! H% }7 X! V0 `7 lAdvancedDocumentProperties 启动打印机文档设置对话框 8 d6 k4 G% k+ Y" I ClosePrinter 关闭一个打开的打印机对象 , [! p6 f, r6 q( B+ {1 fConfigurePort 针对指定的端口,启动一个端口配置对话框 ( J2 h6 a9 b! s+ n- _$ kConnectToPrinterDlg 启动连接打印机对话框,用它同访问网络的打印机连接 8 g( a7 n4 D( _; C: s DeleteForm 从打印机可用表单列表中删除一个表单 ; L- r6 E( C1 I& V1 i% _ DeleteMonitor 删除指定的打印监视器 1 R+ s* A, J' w: X% p1 IDeletePort 启动“删除端口”对话框,允许用户从当前系统删除一个端口 ; S# |2 k$ ? |) U5 ]- V DeletePrinter 将指定的打印机标志为从系统中删除 5 ^+ w$ N4 K) c U DeletePrinterConnection 删除与指定打印机的连接 7 c( i% i @, K8 w# z HDeletePrinterDriver 从系统删除一个打印机驱动程序 ' ?# g0 b9 I6 u# o DeletePrintProcessor 从指定系统删除一个打印处理器 % s& i( @# D) o DeletePrintProvidor 从系统中删除一个打印供应商 6 B: L! N6 n! F# x& [ DeviceCapabilities 利用这个函数可获得与一个设备的能力有关的信息 " x" n+ O$ t; T }$ r- VDocumentProperties 打印机配置控制函数 0 b0 S! B& T K- L4 X; H% C EndDocAPI 结束一个成功的打印作业 5 l1 e, k- X& H$ C& w' A: p- BEndDocPrinter 在后台打印程序的级别指定一个文档的结束 7 F h8 _( S( R% v8 S. w EndPage 用这个函数完成一个页面的打印,并准备设备场景,以便打印下一个页 / T9 K8 W! i# t7 j$ i EndPagePrinter 指定一个页在打印作业中的结尾 ) p$ L% U! q% z+ F% I! G/ M EnumForms 枚举一台打印机可用的表单 % F: b/ s5 R! C9 {9 Q8 cEnumJobs 枚举打印队列中的作业 * b* b4 h! |; \8 z" Z/ J6 { J EnumMonitors 枚举可用的打印监视器 . ~$ [' F, c) `: `$ c EnumPorts 枚举一个系统可用的端口 ) ^/ l* g6 Q: V8 \6 Y$ g7 z; n EnumPrinterDrivers 枚举指定系统中已安装的打印机驱动程序 / V- x' O; }5 K6 _1 Z0 x EnumPrinters 枚举系统中安装的打印机 ' n' _) D9 E5 l: CEnumPrintProcessorDatatypes 枚举由一个打印处理器支持的数据类型 5 q5 h4 K, {2 r4 ]- V EnumPrintProcessors 枚举系统中可用的打印处理器 - a, A5 p$ h" @0 d, d3 R Escape 设备控制函数 - o+ ~' o* Z' V) OFindClosePrinterChangeNotification 关闭用FindFirstPrinterChangeNotification函数获取的一个打印机通告对象 ( P6 ~1 H& l. K& KFindFirstPrinterChangeNotification 创建一个新的改变通告对象,以便我们注意打印机状态的各种变化 % F; x, b5 \+ E. ^FindNextPrinterChangeNotification 用这个函数判断触发一次打印机改变通告信号的原因 / o4 d; N& Z6 Y6 w7 i9 a FreePrinterNotifyInfo 释放由FindNextPrinterChangeNotification函数分配的一个缓冲区 ) [' | Y" C! M+ k; H8 H GetForm 取得与指定表单有关的信息 8 N* |" B2 S {% d& } GetJob 获取与指定作业有关的信息 ! F2 O2 C6 R3 ~& sGetPrinter 取得与指定打印机有关的信息 7 u( Y, O2 I' v' q3 @. P GetPrinterData 为打印机设置注册表配置信息 1 E: `' A ` D- ]& ?* L* \7 h GetPrinterDriver 针对指定的打印机,获取与打印机驱动程序有关的信息 . ]; e1 s1 h- y7 @4 N! k5 ^GetPrinterDriverDirectory 判断指定系统中包含了打印机驱动程序的目录是什么 3 K) P' K. f/ Y4 b/ z6 x/ mGetPrintProcessorDirectory 判断指定系统中包含了打印机处理器驱动程序及文件的目录 3 Z8 g$ Z5 I1 |. C" fOpenPrinter 打开指定的打印机,并获取打印机的句柄 . p$ P8 B9 I1 A4 D1 B0 pPrinterMessageBox 在拥有指定打印作业的系统上显示一个打印机出错消息框 : }0 r8 ~& B8 `4 ]PrinterProperties 启动打印机属性对话框,以便对打印机进行配置 5 ?' U/ i* {1 v ReadPrinter 从打印机读入数据 " L, M& T( W. N, {: AResetDC 重设一个设备场景 % F& W. K9 w% F! K) jResetPrinter 改变指定打印机的默认数据类型及文档设置 ( y6 W7 P; l2 @: nScheduleJob 提交一个要打印的作业 " i+ N1 I4 i; D( xSetAbortProc 为Windows指定取消函数的地址 ( s0 ` q, u8 S' ESetForm 为指定的表单设置信息 0 j2 N/ ^, H( w# DSetJob 对一个打印作业的状态进行控制 6 i' s3 U, P! K! r) wSetPrinter 对一台打印机的状态进行控制 ( V6 C; d" o* g& x1 q4 u SetPrinterData 设置打印机的注册表配置信息 , }0 `5 `4 v8 d8 D8 ] StartDoc 开始一个打印作业 ( a, j' o$ W$ n& Z9 c( O0 G+ l StartDocPrinter 在后台打印的级别启动一个新文档 % Z' x' j7 b5 ]0 ~- W StartPage 打印一个新页前要先调用这个函数 # v1 m/ I; e( {- O% B StartPagePrinter 在打印作业中指定一个新页的开始 $ G- y4 @; X: \% p WritePrinter 将发送目录中的数据写入打印机 ! ?& e7 N1 G3 {: t7 F


作者: ilikenba    时间: 2004-6-1 23:34

看到这样一个usb通讯的帖子,可能对你有用!

主  题: 关于usb通讯方面的问题。请AKing大哥及相关高手来看看,万分感激!!! * J+ S6 l& H5 b作  者: aiyu33 () / G5 W& L2 @5 \( B 等  级: * @; [# H' g: x& E" W信 誉 值: 100 % E8 b8 P. n$ Q4 \. w2 J: z# @所属论坛: C++ Builder Windows SDK/API $ W x9 _. ~3 J+ ~ J问题点数: 100 : w* v! G- Z1 D) H回复次数: 12 ! x0 `% C* X! p9 G2 m 发表时间: 2003-12-16 20:43:13 / e; h! z4 u2 ?! p0 ] * l$ ~. ` E. D 9 G1 @+ I, ~6 A

最今我接到了开发pc和pocket pc通过usb口通讯的任务。这两个星期我参考了很多方面的资料,特别是AKing大哥写的一些文章。但我始终没有打通这个关口,我贴出我的代码请AKing大哥看看,现在很急,多谢。4 z1 V8 Y; m$ |4 C pc的os是windows2000professional3 q. j' h4 ]- s3 x- r0 d4 j pocket pc是hp ipaq 2210,os 是pocket pc2003。- V- u3 [) ?% _+ R, Y( ^2 Y* w! m- g 我装了activesync3.7。我查看过了,这个activesync目录下有pocket pc的驱动程序。pc也能识别。9 q+ L2 S# h) n" X 下面是我在pc上调用usb的代码。 9 y2 r1 e; M' Z0 b- x8 p/ u下面的代码我能打开hidn类型的usb,但是就是不能打开pocket pc的usb。7 c+ F/ L! q0 v$ b" r //classGuid = {25dbce51-6c8f-4a72-8a6d-b54c2b4fc835}8 H! o2 G4 X$ s/ P' j' i! ]1 o% D" ^ DEFINE_GUID(GUID_CLASS_PALM, ( W# U9 o3 t0 }! B7 A 0x25dbce51, 0x6c8f, 0x4a72, 0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0 H7 i( p; u* e& R 0x4f, 0xc8, 0x35); 1 l5 Z& |% d9 ~GUID HidGuid = GUID_CLASS_PALM; N' k0 C" p% M9 [6 U4 P6 e HANDLE Get_DeviceHandle( GUID* pGuid) 4 b4 u+ V% X7 p6 w2 G( E5 Q{3 U1 S. S7 c+ ?, K! _. Q) Y8 b y5 l/ g/ J5 M HDEVINFO info = SetupDiGetClassDevs(pGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); j7 S1 d& t( S- |4 Z) t6 p& [ : g I% ]) R' [* O! _+ E6 E if(info==INVALID_HANDLE_VALUE) , k8 L& G X* c: o" u { 3 G# G$ V1 ?1 m i. |5 L8 i) v printf("No HDEVINFO available for this GUID\n");1 q4 k. ~& R" |2 @# L5 C# S return NULL;& r4 o: U; |0 O$ H3 W# X: Y R } . M6 B4 ?6 [ a$ V+ ?' g. | SP_INTERFACE_DEVICE_DATA ifdata;! {6 [ P2 ~# [" R ifdata.cbSize = sizeof(ifdata);; G: r/ |3 U2 p, Z& | //0000是我在注册表中找到的序号0 Q& k' x' \. O( Y1 U2 d if(!SetupDiEnumDeviceInterfaces(info, NULL, pGuid, 0000, &ifdata))1 c7 X, m3 l( F { 7 N; M- h: Z) Z) ?* P- C2 k( H printf("No SP_INTERFACE_DEVICE_DATA available for this GUID instance %d \n", instance+1); ! b# o' Q$ S9 f4 @5 Z8 T) f SetupDiDestroyDeviceInfoList(info); 1 P$ G& W7 t& a0 M3 I return NULL;1 Z3 r- T i6 X- q' G0 t) P" u }

// Get size of symbolic link name : M7 X- w/ X8 `5 B0 w5 V! v DWORD ReqLen;) E* S% `+ f/ ^ A" g# b / l& W+ i$ ]7 K" L SetupDiGetDeviceInterfaceDetail(info, &ifdata, NULL, 0, &ReqLen, NULL);; F+ y; K# [1 g0 D/ d + `$ l; G4 q7 i0 z PSP_INTERFACE_DEVICE_DETAIL_DATA ifDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA)(new char[ReqLen]);# K, x+ q: g; R ; @2 Q" o1 k* D3 F! [ if( ifDetail==NULL) 9 C5 g% x Y! C9 s) D. L {9 r! i/ `. x% Z SetupDiDestroyDeviceInfoList(info);* N# |2 ]$ U9 H% G; u return NULL;' r0 }9 G# r6 }' k2 B& G }

// Get symbolic link name * x1 a h4 Q8 G) P; L- u% M- x ifDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);1 T- d. ?: o' V P/ c) s* V # O1 r$ ^% l4 S n% Y* I* n if( !SetupDiGetDeviceInterfaceDetail(info, &ifdata, ifDetail, ReqLen, NULL, NULL)) i8 m8 p6 x8 T8 i { $ l4 W* }0 }3 u( U$ m5 ^4 P SetupDiDestroyDeviceInfoList(info);' J' I& B, _8 m4 q delete ifDetail;2 C- W6 e7 N5 F W, {0 Y7 ] return NULL; 7 {8 A! V) o& y; R+ w) d }

printf("Symbolic link is %s\n",ifDetail->DevicePath); ; X8 G1 V0 A& w7 j J/ C: A" ~

/*\\?\\usb#vid_03f0&pid_1016#5&1bc41f6c&0&1#{25DBCE51-6C8F-4A72-8A6D-B54C2B4FC835}这是ifDetail->DevicePath的内容*/6 @; S2 R, m" N- J- F0 F // Open file9 J3 I$ @3 P3 Y( N/ P: r2 D: o //前面都很正常但就是下面始终得出一个无效的句柄,我也就无法开展下一步的工作. ; J* w' S+ U" J$ t HANDLE pDevice = CreateFile(. J- r. |( l- s9 s. c2 m0 `* c ifDetail->DevicePath, 5 F5 X9 v0 E+ S% I+ c, X GENERIC_READ | GENERIC_WRITE, - Y8 [: a: a4 l8 }' ~8 d+ @$ b/ s FILE_SHARE_READ | FILE_SHARE_WRITE, ( H K8 j: ?7 w NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);# j+ P# N/ P: b * D. W3 Q$ ?( i: [) } if( pDevice==INVALID_HANDLE_VALUE) pDevice = NULL;% g! _' o% F" g1 a* F/ ~% U# r( X SetupDiDestroyDeviceInfoList(info); ) a/ o O4 X) J3 E; e7 q 5 m. t% _* D9 a- K+ ~ l return pDevice;' B& G) ]7 ?3 \9 s5 I }! _* @; e: y' R 再次感谢关注这个问题的人们。

+ T* \$ B4 S; }: @ 9 N$ S$ Z! ^8 N ; |. r' h6 o+ X0 n 回复人: constantine(飘遥的安吉儿) ( ) 信誉:101 2003-12-16 21:23:57 得分:0 : a. G& d8 ^/ p3 _$ ^$ A : Z) f3 e+ r4 ]/ v. g / n2 Z l% N5 N & i( A1 M0 ?# S0 D6 [8 p& s* }0 Qstudy

0 r4 b" R8 i9 u2 G & ~' b% ]; m' O; R; XTop ! _$ ^4 V4 N9 p. |- K1 V4 P8 R( @5 v 1 }, T" M" c# D# j2 i) e 回复人: wenyongjie(一个想成为大鸟的小菜鸟) ( ) 信誉:95 2003-12-16 22:28:46 得分:0 + X" `1 y5 v- z4 s0 v / z" J2 v# l9 s. S9 O' F% ? 0 [0 K- b, ~" ?7 L% ^* b8 B ; Z8 l4 B. _' j. @, E 只有学习的份

5 ^9 V# G% @" O, m " G* P3 e! d' WTop % W5 [0 ]5 m) F4 t8 j9 d . s y0 E% A/ { z' Y 回复人: HUANG_JH(保卫钓鱼岛) ( ) 信誉:115 2003-12-17 9:50:41 得分:10 , Z H7 \) u' \5 N; U: U, B5 K . H. V, i" A- y8 }$ m' ` 8 J; D4 g5 n8 @7 B4 z2 N7 n7 Z + |; |# ~9 b$ q) e* T不知道有没有用!

/////////////////////////////////////////////////////////////// 5 h) L6 @7 _5 K7 w7 c9 K! R& l9 n// HW9911 evaluation board software Rev. 1.09 `8 T/ d- a' Y+ G5 t- r& J$ Z // program by Liu Ding, Bei Jing HEAD Elec. 5 N; ^" b7 d( w// this is the main program for the HW9911 USB device evaluation board , d% }# m! ^0 o1 t0 m$ z# `+ S// it illustrate the basical read/write process of HW99112 X% y+ g+ f b" T // by three examples:& L. e N0 E7 z, R0 B // 1. write datas to ram on the evaluation board0 ?+ C' P& c* W9 J# Z5 M // 2. read the datas from the ram on the board 6 c8 t$ F( X# ]8 U8 D// 3. send datas through RS-232 serial prot on the board 8 K, }) h: q( y; s* h// 0 B( R; |; }, n# D// the whole project are build with MSVC 6.0 Q' ?7 G, }/ y& j% U6 E0 p8 @2 A // and tested on windows 98 platform. / x3 k3 c$ U/ f4 [ P//+ X" X- e, n& s0 |- d, c // notes: you can use hyper terminal to reaceive datas form RS232 port0 ^: e8 e; G# A7 {$ l& J4 C- s3 f //, d3 r& _; g5 h( H7 @ V7 E // this software are designed by Liu Ding 3 P K' x. p0 a7 h4 a3 i6 {$ g// if you meet any problems, pls contact by email:' C% [( G- q/ t! G5 X7 r" o // hugehard@263.net+ D# d& j) i" [- `8 z; G9 C* Q // or contact HEAD Co. by Tel 86-10-87312497 & M* i% \. i/ V3 [* g5 S6 p8 O// or by fax: 86-10-87312495$ j' N7 L' d1 A% @4 D6 Z ///////////////////////////////////////////////////////////////

#include "hwdll.h" / P* g3 X' E/ W/ K8 }! X#include "stdafx.h"4 X5 g z6 |9 @/ C0 ~( U #include <stdio.h> - o/ D! ]1 G+ _8 h#include <windows.h> , g* [9 _$ H+ I+ [% K9 z j#include <memory.h># i/ `2 Z3 r6 J9 @8 X- {8 p* t #include <DEVIOCTL.H> . Y k" I: s$ @: G* h6 \+ ]! |9 Y#include <stdlib.h> 5 s& [; A# i. \" M6 o#include <conio.h> + Z; y8 N* P/ _" o% Y6 Z#include "hw9911.h" ' b2 m- P0 _5 i9 k; e#include "test9911.h"

) \- e* G2 H M6 K6 J$ _& y int main() " a/ B+ Z, c; u* p0 {& [{ * T! g0 U' T+ ^8 j3 e int hOpen=FALSE;: A& V. R3 g( P& v int hCommandLength=32;/ m8 j: s4 c2 {5 h% n* w int hDataLength=64;5 |5 m/ G; M2 j* P+ Q7 F3 \, _, i int i,VertAddr=0,HorAddr=0;5 M8 g) z( _( ^2 @ int addr,TotalLen; & |! L8 y4 s7 A; U7 `& ^' M USC StAddrH=0,StAddrL=0;0 k( J% I3 y( _' _4 V' J* l USC DataLenH,DataLenL;( l+ k4 n) H, q) C" V USC *hDataBuffer,*hCommandBuffer; , t; q& ^4 y! y6 | } USC ch1=0x61; - V5 @$ J7 R. |2 z$ z. b HANDLE hDeviceHandle; 3 ^; ~" a6 L! Y: b8 f ' R8 P" a1 Y. D7 `" A7 g printf("************************************************\n"); 4 i4 |7 `' e. m, |, p! w printf("*******HW9911 USB DEVELOPMENT BOARD*************\n"); ( e6 S: l3 a: g; g" f5 j printf("************************************************\n\n"); ) Y) T& p1 f7 g2 S printf("now press any key to open board\n");% q8 ^9 ~) {& ? getch();

/********* call hDeviceOpen in hwdll.dll to open the board***/ 0 w$ P: m! t# M& g//hOpenDevice 说明:6 h5 y }! l) r9 Y2 s6 b // BOOL hOpenDevice(HANDLE *DeviceHandle) . P4 F0 l6 ]/ K, c, o5 _6 H/ ?4 K' J// 作用:打开设备 K7 N8 [$ c/ Z& B, j+ D // 参数说明: 0 X. Z& B; V/ E9 e8 M6 ^// DeviceHandle:设备句柄) W( }" r3 m% V2 h3 G // 返回值:' f9 `1 ^* O C // 设备打开成功返回 TRUE,失败则返回FALSE ! E o: M9 X) L! D7 U if( (hOpen = hOpenDevice( &hDeviceHandle ))==FALSE) 1 W, b t" \4 ^1 R0 E2 j { 8 {! ]2 Z' L) m4 C1 x: d1 f S9 v/ l printf("can't open device\n"); ; a9 v/ M2 r2 K: o8 P, u% e printf("press any key to exit\n"); 0 a5 H: i5 K3 \3 N" g. ~ getch(); - k/ [: a D) d8 p V return 0; $ w) G2 {- ~3 A( f& ?8 H- N+ [& r7 G } 5 z7 O8 I! V! e else " J+ o b$ A1 ~* e7 k9 o3 U; N printf("\nCongratulations! device opened!\n\n");

/****** build and send command **********/9 s, E D5 L* {7 Z3 _/ g printf("how many bytes do you want to access?");, y( A: v0 v1 |! K5 b scanf("%x",&TotalLen);( ^, g7 R1 A. l while(TotalLen > 0x7fff)- ]: {4 h, @1 M8 X- k g { 5 ]& R9 [3 |4 a" e2 U/ i0 x9 a: h printf("pls input a hex data less than 08000\n"); : q4 s3 c% g N' c: K: a% O+ _ scanf("%x",&TotalLen);5 {0 H3 o6 @( T( K } 1 }) d Q( l( T& {( v$ e+ J DataLenH=(USC)(TotalLen/0x100); //data length high bytes! o( m# B2 I6 K6 `' I DataLenL=(USC)(TotalLen%0x100); //data length low bytes

printf("************************************************\n"); % Y" ^3 A; E- S# T/ P printf("now program will write datas to ram on board\n"); f+ j3 J" y. ?" w0 j+ z5 Q printf("total bytes of datas is %x\n",TotalLen);' [4 Q4 r. S) Q7 k printf("press any key to continue\n\n"); 3 r0 M1 q7 P! Q& Z' A0 g getch();+ G$ P) y g7 l* { /***************************************************************** ( A# m: p2 |7 T, i now will build a write command packet $ D" T3 C9 ^9 ^, U7 h% r x with the first byte is 'w'.- W9 T ~: B- M! W: s) c and the following bytes are:. c8 [4 P+ Q' M) b1 f" ~) | start ram address byte high, start ram address byte low, ! h) q7 ~+ {* T. F/ p' _ datalength byte high, data length byte low.8 O" N9 E" q7 ?# [ this packet will send to device through WritePipe1, & T. M4 J, H6 [9 i* o which is endpoint 2 of HW9911. + y9 Z5 A/ A- \$ g when the device receive this command packet,$ v! W; j1 g* y' K it will write TotalLen bytes data to Ram on the board # l; h# G r# Q( D: z2 Z3 j) u l******************************************************************/

' K' W+ j4 G# g; z5 P- Z6 ^ hCommandBuffer=(USC *)malloc(hCommandLength);/ t) N1 h* B* f6 S" Y/ Z hDataBuffer=(USC *)malloc(hDataLength); 7 e8 K% Y! A; s( [( E r hCommandBuffer[0] = 'w'; //read command# g8 ^1 d3 C, y- j4 w hCommandBuffer[1] = StAddrH; : F* A3 p1 Q) u hCommandBuffer[2] = StAddrL; . k7 L; v" u# y) Q& U/ q7 C hCommandBuffer[3] = DataLenH;' o5 k4 ~4 ^4 {8 ?/ C hCommandBuffer[4] = DataLenL;

/* call hUSBIO() in hwdll.dll to send command packet to device*/ : }& H% R; s, g$ ^; T5 ~// hUSBIO 说明:& c. m+ h/ T& _ // BOOL hOpenDevice(HANDLE *DeviceHandle,% f* X- \+ M: ~# P2 E* b4 n // unsigned char *IOBuffer, ' \0 H* w# [* U7 I5 d// int BufferLength, 3 {. _8 b# |- F/ A# b! L$ }. N// int PipeNumber,/ Y1 ]: P% [% r6 m4 D: P( P* b // int Action) . o. B) @. X" m+ z, q( _// 作用:设备读写% h g9 _* S) F D3 e5 t4 [1 f // 参数说明:3 k; u8 a+ u+ W% d7 f4 @" s' c$ m // DeviceHandle:设备句柄 6 @) S; X* O) M8 M* B// IOBuffer: 指向要传送的数据指针2 z1 G5 T: I5 Z6 d( e/ t // BufferLength: 数据包长度# T1 {' B' J* {0 i // 对于发送缓存1、2和接收缓存1、2,BufferLength必须小于或等于32 3 Q P; V: E7 J// 对于发送缓存3和接收缓存3,BufferLength必须小于或等于64' p) D, d4 A: D5 N: e, _' f // PipeNumber: 通道号6 h- I' v/ X5 g2 p // 发送缓存1:PipeNumber=0;5 Y# I' J& {. u% ^/ A9 ~ // 接收缓存1:PipeNumber=1;+ t/ p* @% @' L% x3 z6 S // 发送缓存3:PipeNumber=2; 7 P! v4 s: a& H1 J4 f3 V6 a// 接收缓存3:PipeNumber=3; 0 Q6 q$ O6 Y7 K// Action: 读写标志。TRUE代表从设备读数据到主机/ E) P4 C; E q$ J // FALSE代表从主机发送数据到设备 0 K) k* l8 Y; H7 k3 H, n// 操作接收缓存,Action必须为FALSE/ Z' ]) `/ M, s$ Q: V( f // 操作发送缓存,Action必须为TRUE& v5 P$ l E: X1 b$ M- N. h // 返回值: 4 U. C4 x* ~* `// 操作成功返回TRUE,失败返回FALSE

if ( hUSBIO( &hDeviceHandle, - C6 s# H! W6 S! {6 {! N1 U7 d hCommandBuffer, 1 X4 p2 v* \, A3 g `; r3 A hCommandLength,6 N; W. k2 z0 O @" F/ p- i5 B8 n hWritePipe1,+ v& j3 S D1 T( d( t8 h# X FALSE) == TRUE) - M7 x$ ^' W& \0 r& |$ b! @ { 1 K$ m2 Z+ u [+ K6 ] printf("command 'w' writed to board\n");4 D0 { m" i/ p printf("now press any key to write datas to ram\n");4 q9 _+ l- `9 v: @0 u. m: y- t getch(); g& y" K) ]8 o } i n; y) X7 ]* j- v9 ]+ j else 3 k: y4 U' [6 r2 r+ ^ printf("data can't write to device\n");

/******** write ram data to board **********/

printf(" ");' ^6 I2 j' ~% E: X; e Z for(VertAddr=0;VertAddr<=0xf;VertAddr++) ! A( E; j; B% \3 F6 s6 v4 }- q! P printf("%02x ",VertAddr); 8 Z$ j' {5 }. Z printf("\n");. b6 G6 ?5 I; r, O+ }/ Z addr=0; ( H* B3 i3 v; w1 P& M& R& ]9 _% c while (addr<TotalLen) $ ~+ p/ }+ Q+ h' r0 b { 4 T/ l" v0 z0 i8 @( X7 c if (addr+hDataLength > TotalLen)/ z" k. v4 e9 K6 ?2 W: g# m hDataLength = TotalLen-addr; - `5 T" y1 D/ }8 Q for(i=0;i<hDataLength;i++) 8 S& y. e/ q. g; f1 L } {' A7 q5 Z" y: d1 t% k hDataBuffer=ch1++;; u$ C8 S% ^; U& Y if (ch1 > 0x80) & K; ^3 Z0 S" X- @1 M. ]; V; t ch1 = 0x61; $ U4 s t1 x3 `8 d2 a2 u }7 z. L4 I; }; j3 X /* call hUSBIO to write datas to write pipe3, which, }2 w4 m' s% a is endoint 6 of HW9911*/

if ( hUSBIO( &hDeviceHandle,+ U& v* I9 A& j1 a% o/ s hDataBuffer,. Y* [ o3 B Y+ Y hDataLength,; f5 j. e, w2 a. B m hWritePipe3, 5 U: }- Y1 s& X. X. u' b FALSE) == TRUE) //FALSE means Write operate 9 S0 g/ {: I2 p2 ] {$ L3 j) \! E( Y! o9 u8 @ for(i=0;i<hDataLength;i++) 5 D% S0 I& j8 Q3 F {0 V7 K" T; D* z: E1 _2 K5 X /* print format control */ # n/ U4 s2 i3 w, f: Q9 R& c if(i % 16 == 0) / b- r6 |! H. P6 ?. v } { , `: C4 q6 N( W% }. v printf("\n%04x ",HorAddr);6 l" o5 B6 X- K. ^7 Q* V HorAddr=HorAddr+16; ( _: p$ g+ W. O" q% A) R } * j. O' Y# u# Z/ p printf("%02x ",(USC)hDataBuffer); " K5 ]8 W* @' j2 I% q# b. b K } S; N1 M$ [ y9 s addr=addr+hDataLength; 3 v' T. J1 A. p/ ? N }! ?3 z% L/ r: O9 Y' U V else , P6 l6 b* E, G3 E7 l& e {! i* M; ~7 a F3 n' c( r+ @ printf("can't write to board\n"); / b" Q0 P. m. V6 H exit(0); & f4 x; I" p% s9 j } 6 Y7 _) ^( Q: _+ j5 L7 J# @! [! R }! _; V, o% J3 O# A2 `, _ printf("\n\nTotal%x bytes write to ram OK\n\n",TotalLen);

5 ]& N. O5 L9 w( _, x) ?% L + t7 @5 I" n( A3 n' d6 u Top : e! m) {0 T: U4 [6 k & }, v$ `' G- U( Y2 X# t5 @- x 回复人: HUANG_JH(保卫钓鱼岛) ( ) 信誉:115 2003-12-17 9:50:51 得分:0 + v. R- d1 o+ q5 Z) g - @* O$ ^5 k/ d8 Q) v J + T: N I- B4 W' R: ]/ r

/***************************************************************** 4 B4 x; P7 n) p+ J now will build a read command packet ; J) R% p1 {( M( S with the first byte is 'R'. ) b# J7 M6 ]$ f/ c2 ^& v and the following bytes are: 3 q2 [$ u. M# A% t0 f start ram address byte high, start ram address byte low, % O) S% i; ?2 F0 g# L- o datalength byte high, data length byte low. ! X1 B, M I' J v J7 e+ B this packet will send to device through WritePipe1,3 @5 p! |! [$ [% y, O8 ] which is endpoint 2 of HW9911.2 ^% h( F( u: j when the device receive this command packet, 8 u3 G% }% t8 x& p0 v it will read TotalLen bytes data from Ram on the board 2 F1 y/ ^' H9 U& p* q4 n* X******************************************************************/

printf("************************************************\n");) w$ B8 ~" Y( X# g printf("now program will read datas from ram on board\n"); ) ~- n* O1 S! _- [ printf("total bytes of datas is %x\n",TotalLen);+ n" h4 n+ z @$ A5 |: x) F printf("press any key to continue\n\n"); & {- s* @6 o+ H getch(); 9 N- @: K) S0 N& t% D. M! T hDataLength=64;8 X7 C! o2 s' C. y hCommandBuffer[0] = 'r'; //read command0 l( c2 z: e; h, v hCommandBuffer[1] = StAddrH; : I5 s$ E/ N1 B! q hCommandBuffer[2] = StAddrL; 1 a8 q+ _' ]$ K& a3 R) v, j y hCommandBuffer[3] = DataLenH;8 J' u. E+ E; s; [. f W2 m hCommandBuffer[4] = DataLenL; # q/ O# e$ W2 f- ~+ f /* call hUSBIO to send packet */4 f7 {# s: ^1 n" |; L if ( hUSBIO( &hDeviceHandle,' B D u( M8 g( g" I6 s hCommandBuffer, 1 H; U$ s: W6 S% G5 ^$ h: H! c) Z1 ` hCommandLength, " {. U2 Q5 I; I, k$ O hWritePipe1,# l5 i- \( j9 t1 w5 a% b5 z FALSE) == TRUE) % t3 E' s0 `; [9 K { # J5 K, Z3 k* q. l* Z U' P# I$ Y printf("command 'r' writed to board\n"); " |+ F- `/ { e) K/ G printf("now press any key to read datas from ram\n\n"); ( n7 `) T' T* e* ]& \- p p getch(); E) }1 I4 t! a4 h! k3 b8 A } # H& m6 `5 T3 N( [" J. N4 X else k, n/ `) D* v printf("data can't write to device\n");

/******** read ram data form board **********/ 3 r" r @1 R0 g. E( `1 j( w$ P S% q printf(" ");8 s5 ]# F" ^2 m2 B for(VertAddr=0;VertAddr<=0xf;VertAddr++)( `0 w0 B# A% O; q6 n# g: [ printf("%02x ",VertAddr); # i- g8 t1 `* c4 E/ s) }: B printf("\n");" B3 g; `% H% D* @# K8 ~ addr=0;% D3 ~) c0 C8 S8 Z HorAddr=0;" H/ ]! `* F) V) w% `% s while (addr<TotalLen) / A: V; l7 d9 i5 g; t. {# L+ a {( G0 \# K8 b9 w if (addr+hDataLength > TotalLen) % j% @% Z: _2 F) a; \ hDataLength = TotalLen-addr;! `5 k- t4 l& } /* call hUSBIO to read datas from board */ 3 {7 F- Q2 U, ]! ^( c; O if ( hUSBIO( &hDeviceHandle, 4 }* F- f7 ]" t7 N# W hDataBuffer, - P, ?3 y5 I* r7 d2 d8 K+ |% D hDataLength,( T: }0 P" L$ } hReadPipe3,; r5 H0 ^5 ~" y/ t. b7 @0 G TRUE) == TRUE) //TRUE means Read Operate 3 X9 ]2 w1 [# g$ n- [ { ' y7 G; L, _) G4 v# t for(i=0;i<hDataLength;i++)8 u) I0 a9 \5 T {- ?* y9 S5 P; O/ E /* print format control */ 9 q6 Z# Y6 \& V2 n8 k if(i % 16 == 0) . h. R9 @* J6 u* L {8 p; `7 t+ a0 S* N* p7 `- f printf("\n%04x ",HorAddr);, z0 [6 n T9 T+ d$ o. t HorAddr=HorAddr+16; ( B) V( \, v, ]& M: f8 P }: ?8 f& m' w% Q4 ?9 q- }+ Q% R printf("%02x ",(USC)hDataBuffer);4 `5 | f6 o2 d+ G6 g } * {5 U* E5 {# q- s% v addr=addr+hDataLength; 1 p( L2 Y9 K; k( v# ] } 6 K" P3 P- O. Y: C- S else & l9 o. ^3 x5 t* [& E { ) v' O5 \6 |; P* l8 D printf("can't read from board\n"); ]) V& N" s& a1 L/ q exit(0);! s9 A8 T0 _. i } 1 i' r# s7 D) l {* G }5 S# ]: @1 ?" j3 ]: {: c1 Y. L2 d printf("\n\n"); ' ]/ n5 g! M, O& [0 K3 ^! u printf("%x bytes read from ram OK\n\n",TotalLen);

/*****************************************************/8 C. _8 V6 P" J, k1 H: c+ f4 H /* process rs232 test */ 8 e" v1 ~0 x( O/* the first byte in this packet is command 's' */ ! D# F9 ^. n( } l, l+ p' E/* and the following 2 bytes are used to set */ 7 M3 \' @( y' O$ Y: {' @! y/* the baud rate of 8051 */ 6 B+ D' x$ ]' P7 N) \2 X/* they will be write to TH1 and TL1 respectively*/ " X% I1 U; R* S K: a' G1 F7 J4 @/* the following bytes are datas will be */& u! V9 Z- A2 F8 ^( S) i1 B9 u /* send through RS232 serial poart */4 |) u, ?( H2 c& _ /*****************************************************/$ V& w& D/ w) L, d9 S9 w" q5 l printf("\npress any key to process RS232 Test\n"); 7 O' k# }/ v' N5 U getch(); & e8 V. b! a( G& A - o( b- `' E" `4 q USC TH1,TL1; 2 N, U1 t/ p" k1 X7 g char hStr[30]; ; C3 @ {7 g2 v9 c& n1 q TH1=(USC)(BD9600/0x100);- b/ A8 P' q: D, q' l9 M- B+ a O TL1=(USC)(BD9600%0x100);5 M6 i( T: d3 E3 ] hCommandBuffer[0] = 's'; //read command8 V7 i) d( e6 R7 W/ v: p H- y/ H hCommandBuffer[1] = TH1; % q4 j: c( n5 W6 v5 b hCommandBuffer[2] = TL1; //start address is 0x0000

strcpy(hStr, "Hi, dear HW9911 consumers! ");/ C! j( }3 e/ S' @( s. } printf("Hi, dear HW9911 consumers! "); / T+ o6 b9 S% \9 P+ t9 N2 @, y memcpy(&(hCommandBuffer[3]),hStr,27);

if ( hUSBIO( &hDeviceHandle,$ H; w5 G3 v% O) u5 i2 H hCommandBuffer, 0 S: U5 G+ x9 F; X* g3 X, a- U2 x 30,/ N! J, U7 u L, o hWritePipe1, 8 w- M, N3 {, m9 a5 E) ? FALSE) == FALSE) 7 S v+ j0 b8 } { 4 A7 Z6 W J& S printf("can't write datas to RS232\n");% g4 H% A6 U: S& }- Y exit(0); ( Z3 s8 j' t; `' d }

strcpy(hStr, "I'm HW9911 Evaluation Board, "); 9 @. K1 O2 L$ s8 n. Z4 B printf("I'm HW9911 Evaluation Board, "); l, {$ N# i, {9 T. n memcpy(&(hCommandBuffer[3]),hStr,29); ; }) |! b8 J1 H8 z 5 I" y+ y( m `3 T, ^. t6 M/ X if ( hUSBIO( &hDeviceHandle,- R; W: j3 {& X9 l hCommandBuffer, $ Z4 ~) e- b; q2 r* |( ^7 t5 Z 32,2 T) V4 r3 p# f0 D+ v hWritePipe1, & ^& L* B+ q; c# W4 J3 H FALSE) == FALSE) 0 b( t6 ? _: J { / l. F. y) J3 o1 k, t5 G printf("can't write datas to RS232\n");, g: ~# {! x$ y exit(0);2 {, v+ C% H2 m8 K j7 T; }7 m8 _ }

strcpy(hStr, "thanks for purchasing me, "); # x4 A: |! U5 _& w3 C( p printf("thanks for purchasing me, ");. x! v' H4 ?; ]/ \) z q memcpy(&(hCommandBuffer[3]),hStr,26); 3 A2 h6 L+ _: T V5 {2 V/ B( J 9 Q+ y8 r+ a, P a# r if ( hUSBIO( &hDeviceHandle,2 C1 k1 r: Y) S# M. ? hCommandBuffer,) q2 e% m- I, k! R% G 29,# @$ \( w3 p( J: {6 Q hWritePipe1," Y5 u% U5 `: j9 r; d7 ] FALSE) == FALSE) 2 R4 X. K- i& }6 x6 K* v, T4 O2 L+ y {: v: B) @+ V, c, W. m printf("can't write datas to RS232\n"); P& ^5 T) E# U2 k# ^: X: K exit(0);8 H& J" M" _- C2 x }1 |- _ P2 b5 \) v3 H( G& | # K) ]' v' U8 r5 I: ` strcpy(hStr, "If you meet some problems, "); ! G2 n1 D8 ]' R! q. J* K. h printf(hStr, "If you meet some problems, "); : p4 K; M. a, m3 v% ?5 ?, C! ` memcpy(&(hCommandBuffer[3]),hStr,27); 3 R# u% ^$ }" {( d$ F 6 i2 [ g; C5 P1 j7 b if ( hUSBIO( &hDeviceHandle, - G1 ?! T7 q I hCommandBuffer,$ T: K d# l. C. A 30, , P3 H" f6 `9 B. u3 y) o: G hWritePipe1, ) ? d+ {: m2 o FALSE) == FALSE) 1 d* k% O8 ?4 x8 C/ o N. O7 Q { 3 r9 o( ? e) Z+ E& m printf("can't write datas to RS232\n"); * _3 k( P8 j; B% o& z exit(0); - v9 m. v/ }6 S! H& O, t$ D" d }

strcpy(hStr, "pls contact my designer "); 4 S& i( o0 t9 `0 g4 u; B printf("pls contact my designer ");; ]/ ]/ V" T" A4 c memcpy(&(hCommandBuffer[3]),hStr,24); U& ?: ^" f) p7 Y* B 9 L9 D: U1 M" z+ r$ }& m+ q if ( hUSBIO( &hDeviceHandle, 3 l. S ], M9 K hCommandBuffer,! x7 A) d! X$ b& V& n 27, 6 s! _! O& j. d3 c* d hWritePipe1,( I& j% G4 |7 E' Y" i( ` FALSE) == FALSE)0 j% T3 l+ p7 R; O& L { ) A% ^& G+ U; ~& S2 [ printf("can't write datas to RS232\n");% p0 J! I4 w; A9 G. w exit(0); * ]- _6 u3 E3 o: p }

strcpy(hStr, "by email: hugehard@263.net.");8 J) @0 m. j1 ]! [! o( v0 D printf("by email: hugehard@263.net.\n");1 k7 i) z1 N8 _. ?2 E memcpy(&(hCommandBuffer[3]),hStr,27);* h. J# n; J i& H# u- w/ I, c Q ' f1 [" }5 m) O5 m if ( hUSBIO( &hDeviceHandle,! D n1 p2 q, H6 |: j! X hCommandBuffer,7 U7 K* L/ c0 r# U 30,2 g" e+ z( ?# t. E, U" X, Z hWritePipe1,. A/ r& V" M' N- ? FALSE) == FALSE)# e, K& x' c. V3 c6 J {6 O" ]; R$ j( b printf("can't write datas to RS232\n"); 3 T9 B" p. h9 E9 r% f- ~, o exit(0);! O* I+ `1 ]4 n/ t" Z# n } : Y* J2 K4 V! G, S! V/********* call hDeviceOpen in hwdll.dll to open the board***/6 ` F1 W3 G/ X( N8 l) A- t // hCloseDevice 说明: 7 }+ g" C) d, M, m* M4 H// BOOL hCloseDevice(HANDLE *DeviceHandle) # y; X8 `4 s7 S, E" M& e% @2 T( Z: x8 t// 作用:关闭设备: k" `9 F2 Q" g) B% [ // 参数说明:/ j% t1 j& \. h% a# K& w // DeviceHandle:设备句柄 3 _) G0 ?9 X2 Y6 ? h) |// 返回值:( w% N& c8 n' J, p" V; n2 t( L% Y$ C // 设备关闭成功返回 TRUE,失败则返回FALSE: f6 h9 c/ K: I* n" s if( (hOpen = hCloseDevice( &hDeviceHandle ))==FALSE) ' H. q+ }( W2 ^) s { 3 u2 m4 \' r' p$ w4 ^2 I printf("can't open device\n"); ' f( ~$ V u/ E/ u O. ^ printf("press any key to exit\n");5 M$ L0 y- N' s+ v: I6 T- K getch(); 8 Z& U1 o4 f; s2 m# \ return 0;4 ~8 M0 N2 t2 t2 t4 Q } ' T7 N. V9 R; `6 Z4 e3 I3 M' z else . X" Q, X- v+ W) @: ?8 @) ]6 h printf("device closed\n");

printf("press any key to exit the program\n"); " f& Q7 [( T7 k9 b free(hDataBuffer);3 S0 ~5 x% R9 f3 [9 }' N free(hCommandBuffer);# {1 R* V- g) F& r' K4 a, [% c8 l getch();, T& y- X( q4 P5 ^3 F return 0;$ H0 `& p! G* j }

: B8 W5 u' `" |, E' A3 s ( p N8 |+ ?- W/ m* W! v# R7 V" a8 g1 ` 1 b4 F' f( Q7 {9 _* UTop ' H/ y7 M9 l& Y7 J- U # }6 |1 e9 |( G+ R. p 回复人: aiyu33() ( ) 信誉:100 2003-12-17 11:41:24 得分:0 ( m7 F& L1 v, L& V : c( K$ t) o5 i3 ~/ ]$ |( x 6 y* e. \* Z4 f# C& q3 A " W: E5 D" n, E+ o. l. h upupupupupupup

5 X, W) o3 K( j( j5 e$ z) R 8 F c# R/ }" } Top : U8 O; Y: g/ @ \( s1 n 9 A& P, a$ {0 G3 j6 R' g 回复人: kingcaiyao(AKing) ( ) 信誉:110 2003-12-17 12:53:39 得分:0 4 i7 w2 R# v s) Z1 {" \ : b3 Z, k. C9 D, f! ^ : D$ F7 @$ o5 U5 t9 k. X - T& g0 T+ c* `7 Q4 |你开发的这种软件类似于Palm Desktop Software,负责Pocket与PC之间通讯,我建议你最好先写一个驱动,将USB口虚拟成一个串口,然后直接对串口操作会很方便的。我现在做的程序可能和你相似是一个CDMA模块,通过USB口与PC机连接,然后由驱动程序将它虚拟成一个串口,我的工作就是和这个虚拟的串口通讯。

% P" b* W) l2 t" q: j 0 W. Z) `8 H9 b' _ Top : S+ X+ f N; M8 X% _, b 6 c9 e& m( ?1 L" L7 q# N 回复人: kingcaiyao(AKing) ( ) 信誉:110 2003-12-17 12:56:27 得分:0 # ]3 A, k8 G: c/ D 9 z; k1 B7 L9 J# a/ \4 y$ D/ y/ v# o ( Z) `/ X( r8 g4 V, C7 U6 r 3 S/ g% O6 K$ ~ H1 y1 d3 t; D+ E Pocket与PC连接肯定有驱动的,如果驱动程序没有将Pocket虚拟成一个串口,你也可以直接通过设备GUID和设备序列号进行访问,详情你参见我专栏上的一篇文章。当然了,通过虚拟串口来访问设备肯定要方便,简单些。

' G2 p. q( V0 q, F, H # M) q: \- x4 sTop 3 a% I% h7 ]) {& e# c : f, p& T' t- ]. @% a 回复人: aiyu33() ( ) 信誉:100 2003-12-17 13:31:08 得分:0 # g6 m4 s0 `" ^: ] ; z2 I: D6 v; R" X8 U8 Y 2 w7 C, {$ }1 Q% Z. n. c: C ) V8 L7 e. [: h. Q: V- c: u 我得这款pocketpc默认只支持使用usb与pc相连的,而且activesync3.7就是使用usb传输数据的。如果我自己写驱动的话,不仅不熟悉而且很可能activesync3.7这个软件就使用不了。我只需要利用它的驱动。你的专栏上的那篇文章我也看了,我就是模仿你的写的代码,但就是到createfile这步就不行了,我的同事是用palm开发类似的程序,也是到这步就行不通了,是不是有其他的原因?7 J- j2 ]% D- L: m 我还想问问如果驱动程序将pocket虚拟成串口,如何查看它的符号名呢?

' w) o& T1 ^+ \. r4 a 8 {, ]6 ^8 ]3 Z. }4 Q' X + s% j: ?5 A; Q& `& G1 N2 f Top 8 H% Q5 y1 _4 ^ u! R% A7 A . d. Q1 k7 Q7 t6 w& P: F% G5 {8 X0 K 回复人: kingcaiyao(AKing) ( ) 信誉:110 2003-12-17 16:53:17 得分:0 , [0 ]( k( Z k( G4 L2 Y: [ + A1 F" ]8 l8 F$ {7 i: q / H! U" \6 Y0 K9 h% I# ^ 4 b ~1 Q- V: y7 p 假如将一个USB设备虚拟成串口的话,那么它的符号名可能是COM3,COM4,或COMn,这根据你当前PC机的配置而定 。它的符号名位于注册表中HKEY_LOCAL_MACHINE\CurrentControlSet中,你可以搜索注册表,另外在2000或以上的操作系统中,你可以到HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SerialComm中看到。

5 O: B( w& s% ~5 h1 D " o7 l8 X* J7 S g' O Top l; n! n, x: ?& m . N& o/ K& ]% P) m1 {# p 回复人: kingcaiyao(AKing) ( ) 信誉:110 2003-12-17 16:55:33 得分:0 7 V% T* X- Y. t, t / d% B1 k1 R L. \" ?" u# V7 g 9 r% x7 ^$ m: U8 X. A P3 { + ]; z9 L! }7 V. s5 a 我以前在一张贴子中详细回答了如何利用设备序列号和设备GUID来访问该设备,你可以搜索一下CSDN。你所说的CreateFile不能打通设备,你要查一下,你的符号名是否正确,包括设备序列号和设备GUID是否正确,设备GUID你可以从驱动程序的安装向导文件.inf中找到,设备序列号则需要你到注册表中去找。

5 C( u) @4 X" J. A8 l/ G 2 V% r ~, F% K" k& E/ CTop ) h4 n, h! t9 o% ~' Z ) r1 i' k' O) K2 I 回复人: gyj_china(透明) ( ) 信誉:98 2003-12-17 18:15:30 得分:90 - ?6 b8 w7 C+ Y % C" }" G/ H& j3 ^2 e5 ]( P1 |: h B + @; C4 _8 [% F& r4 Q7 ? " M& A+ ~" A; B9 r 没有星星不敢发言:(

0 n0 s: _5 l( a& i" m , ~ G6 `, b3 P0 i" z. n" ~ } Top / D1 E0 Q y, F' q/ ~& ` 1 L% O$ e9 E# |1 z A# H+ f 回复人: aiyu33() ( ) 信誉:100 2003-12-19 18:27:28 得分:0 - Y3 K+ M# k0 S1 |8 b& N% l! { # S% ~* E% x- l* w. e 1 x6 d0 h0 f( m; p! U. G1 { 4 r; g3 x2 u0 f, C9 P; q不好意思,是因为ActiveSync3.7一直在系统服务程序中运行,占用了驱动程序,所以不能打开设备。我删除了ActiveSync3.7后就可以了。


作者: kenneth    时间: 2004-6-2 10:36

大哥太好了

3 M; B* z3 c, h

正是我想要的

$ k6 {" {# s. w% _ [- i, m

謝謝你


作者: 闹市的牧羊人    时间: 2010-8-11 08:35
看不懂         
作者: arvinlai    时间: 2011-8-2 11:25
啊 啊啊 看不懂啊
作者: arvinlai    时间: 2011-8-2 11:25
啊 啊啊 看不懂啊
作者: 幽幽蓝水    时间: 2011-9-19 21:07
啦啦啦 谢谢
作者: www.qqqzq.com    时间: 2011-11-22 06:26
我是刚注册的新手 请各位大哥多关照- c; Z0 [+ Q5 l& \9 |: `$ w3 J# g

作者: MichaeLonger    时间: 2014-6-18 21:13
路过。。。
作者: MichaeLonger    时间: 2014-6-18 21:13
水水。。。
作者: hitshijian    时间: 2015-2-3 10:25
赞一个!!!/ F3 y" d) Z2 K

作者: SHERE201506    时间: 2015-8-26 11:00
谢谢楼主# G  H2 p& Y9 ^) @6 P

作者: SHERE201506    时间: 2015-8-26 11:00
谢谢楼主
; `9 D* [! Y/ [9 O* W+ {




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5