微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > ARM技术讨论 > 用vc++ 实现与usb相连 求大神挑错 下面是程序

用vc++ 实现与usb相连 求大神挑错 下面是程序

时间:10-02 整理:3721RD 点击:
#include <iostream>
#include "stdafx.h"
#include "windows.h"
#include "Setupapi.h"
#include "stdio.h"
HANDLE CreatFile
DWORD dwDesiredAcess,//访问模式
DWORD dwShareMode,//共享模式
LPSECURITY_ATTRIBUTES lpSecurityAttribute,//通常为NULL
DWORD dwCreationDistribution,//创建方式
DWORD dwFlagsAndAttributes,//文件属性和标志
HANDLE hTemplateFile,//临时文件的句柄
);
HDEVINFO SetupDiGetClassDevs
(
IN PGUID ClassGuid,//classguid :任意指向一个安装类或接口类的GUID
IN PCTSTR Enumerator,//enumerator:任意指向一个字符串,它过滤返回的设备
IN HWND hwndParent,//给出与该信息集的成员有关的任何拥护接口所用的顶层窗口句柄
IN DWORD Flags,//给出构造设备信息集时所用的控制操作
);
SetupDiEnumDeviceInterfaces
(
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN LPGUID InterfaceClassGuid,
IN DWORD MenberIndex,
OUT PSP_DEVICE_INTERFACE_DATA DeviceInterface_Data
);
SetupDiGetInterfaceDevicrDetail
(
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVICE_INTERFACE_DATA DeviceInterface_Data,
OUT PS_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData,
IN DWORD DeviceInterfaceDetailDataSize,
OUT PDWORD RequiredSize,OPTIONAL
OUT PSP_DEVINFO_DATA DeiceInfoData OPTIONAL
);
typedef stuct
_SP_DEVICE_INTERFACE_DETAIL_DATA_A
{
        DWORD cbSize;
        CHAR DevicePath[ANYSIZE_ARRAY];
}
SP_DEVICE_INTERFACE_DETAIL_DATA_A,*PSP_DEVICE_INTERFACE_DETAIL_DATA_A;
//部分程序
HANDLE hOut;
hOut=CreatFile
(
pDetail->DevicePath,GENERIC_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,
NULL
);
BOOL ReadFile
(
HANDLE hCom,
LOPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOverlapped
);
BOOL WriteFile
(
HANDLE hCom,
LPCVOID lpBuffer,
DWORD nNumberOfBybesTOWRITE,
LPDWORD lpNumberOfBytes Written,
LPOVERLAPPED lpOverlapped
);

我是在VC6.0上做的  学校实验室软件版本比较低

前来观摩学习,希望有用!

做出来会有用的

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top