www.pudn.com > BiosNtSuiteBin.rar > VCDlg.cpp
// VCDlg.cpp : implementation file
//
#include "stdafx.h"
#include "VC.h"
#include "VCDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVCDlg dialog
CVCDlg::CVCDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVCDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVCDlg)
m_biosID = _T("");
m_biosType = _T("");
m_OEMInfo = _T("");
m_Name = _T("");
m_SN = _T("");
m_biosDate = _T("");
m_RegisterKey = _T("");
m_ChipsetID = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVCDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVCDlg)
DDX_Text(pDX, IDC_EDIT1, m_biosID);
DDX_Text(pDX, IDC_EDIT2, m_biosType);
DDX_Text(pDX, IDC_EDIT3, m_OEMInfo);
DDX_Text(pDX, IDC_EDIT4, m_Name);
DDX_Text(pDX, IDC_EDIT5, m_SN);
DDX_Text(pDX, IDC_EDIT6, m_biosDate);
DDX_Text(pDX, IDC_EDIT7, m_RegisterKey);
DDX_Text(pDX, IDC_EDIT8, m_ChipsetID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVCDlg, CDialog)
//{{AFX_MSG_MAP(CVCDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCDlg message handlers
BOOL CVCDlg::OnInitDialog()
{
CDialog::OnInitDialog();
AfxOleInit();
// 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
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CVCDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CVCDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CVCDlg::OnButton1()
{
try {
IBinfoNtPtr pIBios(__uuidof(BinfoNt)) ;
UpdateData(TRUE);
if(m_Name.IsEmpty())
pIBios->PutUserName("Anonymous");
else pIBios->PutUserName(m_Name.AllocSysString());
if(m_SN.IsEmpty())
pIBios->PutRegisterCode("Anonymous");
else pIBios->PutRegisterCode(m_SN.AllocSysString());
if(m_RegisterKey.IsEmpty())
pIBios->PutRegisterKey("53c3-1234567890");
else pIBios->PutRegisterKey(m_RegisterKey.AllocSysString());
m_biosID =(char *) pIBios->GetBiosId();
m_biosType = (char *) pIBios->GetBiosType();
m_OEMInfo = (char *)pIBios->GetOEMInfo();
m_biosDate = (char *)pIBios->GetBiosDate();
m_ChipsetID = (char*)pIBios->GetChipsetId();
}
catch (_com_error e) {
AfxMessageBox(e.ErrorMessage());
}
UpdateData(FALSE);
}