📄 deviceexdlg.cpp
字号:
// DeviceEXDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DeviceEX.h"
#include "DeviceEXDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDeviceEXDlg dialog
CDeviceEXDlg::CDeviceEXDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDeviceEXDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDeviceEXDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDeviceEXDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDeviceEXDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDeviceEXDlg, CDialog)
//{{AFX_MSG_MAP(CDeviceEXDlg)
ON_BN_CLICKED(IDC_INITDEVICE, OnInitdevice)
ON_BN_CLICKED(IDC_UNINDEVICE, OnUnindevice)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDeviceEXDlg message handlers
BOOL CDeviceEXDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
//CString str=_T("动态驱动加载");
::SetWindowText(CWnd::m_hWnd,_T("动态驱动加载"));
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CDeviceEXDlg::OnInitdevice()
{
// TODO: Add your control notification handler code here
//加HKEY_LOCAL_MACHINE会出错,我试过N*N次才搞定,不要走我的弯路.
//hDevice = ActivateDeviceEx(TEXT("HKEY_LOCAL_MACHINE\\Drivers\\USB"),NULL,0,NULL);
//把USB改成你的驱动所在的注册表位置就可以了.
//记得调试时不要放在WinCE自动加载的位置哟!!!!!!!!!!(不要放在这个键下面:Drivers\BuiltIn)
//调试完了把在驱动里把注册表改为Drivers\BuiltIn\你的驱动,这样WinCE启动时会自动加载.
hDevice = ActivateDeviceEx(TEXT("Drivers\\USB"),NULL,0,NULL);
if (hDevice)
//GetDlgItem(IDC_STATIC)->SetWindowText(_T("驱动加载成功!"));
::SetWindowText(CWnd::m_hWnd,_T("驱动加载成功!"));
else
::SetWindowText(CWnd::m_hWnd,_T("驱动加载失败!"));
return FALSE;
}
void CDeviceEXDlg::OnUnindevice()
{
// TODO: Add your control notification handler code here
::SetWindowText(CWnd::m_hWnd,_T("卸载驱动并退出!"));
DeactivateDevice(hDevice);
EndDialog(IDOK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -