📄 ejectusb.cpp
字号:
// EjectUSB.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <stdlib.h>
#include <windows.h>
#include <SetupAPI.h>
#include <cfgmgr32.h>
#include <iostream.h>
#include <fstream.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
//int res = 0;
char USBDeviceName[100];
ifstream InPort;
InPort.open("USBName.txt",ios::in,0);
if(!InPort)
MessageBox(NULL," Cannot find file","MSG",0);
InPort >> USBDeviceName;
InPort.close();
MessageBox(NULL,USBDeviceName,"MSG",0);
//char* hid = "USB\\VID_0471&PID_0188\\0002F685D6A10F97";
HMACHINE hMachine = NULL;
DEVINST dnDevInst = NULL;
PDEVINST pdnDevInst_OUT = &dnDevInst;
CM_Locate_DevNode_Ex(pdnDevInst_OUT, USBDeviceName, CM_LOCATE_DEVNODE_NORMAL, hMachine);
//_itoa(res, buffer, 10);
//MessageBox(NULL, buffer, "msg", 0);
CM_Request_Device_Eject_Ex(dnDevInst, NULL, NULL, 0, 0, hMachine );
//_itoa(res, buffer, 10);
//MessageBox(NULL, buffer, "msg", 0);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -