📄 usb.cpp
字号:
// USB.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "USB.h"
#include "USBDlg.h"
#include "main.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
HANDLE m_hDevice;
#define MAX_DRIVER_NAME 255
/////////////////////////////////////////////////////////////////////////////
// CUSBApp
BEGIN_MESSAGE_MAP(CUSBApp, CWinApp)
//{{AFX_MSG_MAP(CUSBApp)
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUSBApp construction
HANDLE WINAPI EzusbOpen()
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
char pcDriverName[MAX_DRIVER_NAME] = "";
HANDLE hDevice=NULL;
for(int i =0; i<32; i++)
{
sprintf(pcDriverName, "Ezusb-%d", i);
if (bOpenDriver (&hDevice, pcDriverName) == TRUE)
{
//AfxMessageBox(pcDriverName);
break;
}
}
if(i==32)
return NULL;
return hDevice;
}
//-----------------------------------------------------------------------------
CUSBApp::CUSBApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CUSBApp object
CUSBApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CUSBApp initialization
BOOL CUSBApp::InitInstance()
{
AfxEnableControlContainer();
HANDLE hObject = CreateMutex(NULL,FALSE,"CHINAYCLL");
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hObject);
AfxMessageBox("程序已经运行!");
return FALSE;
}
// Standard initialization
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
SetDialogBkColor(RGB(100,128,128),RGB(0, 0, 0) );
m_hDevice=EzusbOpen();
if(!m_hDevice)
{
AfxMessageBox("不能打开USB设备!");
//return FALSE;
}
CUSBDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -