Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
OpenByIntf.cpp
Package: TX-1C-usbdriver.rar [view]
Upload User: lyfy_2008
Upload Date: 2014-07-13
Package Size: 3016k
Code Size: 1k
Category:
USB develop
Development Platform:
Visual C++
- // OpenByIntf.cpp - open device by device interface
- // Copyright (c) 1998 Compuware Corporation
- #define NOCRYPT // prevent attempt to include missing files
- #define _INC_EXCPT // prevent excpt.h from being included
- //#include <stdlib.h>
- #include"stdafx.h"
- #include <windows.h>
- #include <winioctl.h>
- #include <devintf.h> // DriverWorks
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG-NEW
- #endif
- // OpenByInterface
- //
- // Opens the nth device found with the given interface class
- HANDLE OpenByInterface(
- GUID* pClassGuid, // points to the GUID that identifies the interface class
- DWORD instance, // specifies which instance of the enumerated devices to open
- PDWORD pError // address of variable to receive error status
- )
- {
- HANDLE hDev;
- CDeviceInterfaceClass DevClass(pClassGuid, pError);
- if (*pError != ERROR_SUCCESS)
- return INVALID_HANDLE_VALUE;
- CDeviceInterface DevInterface(&DevClass, instance, pError);
- if (*pError != ERROR_SUCCESS)
- return INVALID_HANDLE_VALUE;
- hDev = CreateFile(
- DevInterface.DevicePath(),
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL
- );
- if (hDev == INVALID_HANDLE_VALUE)
- *pError = GetLastError();
- return hDev;
- }