CString str = TEXT("字符串 ");

IP.SetAddress((DWORD) tmp);

对Combo Box设置当前显示 SetDlgItemText( HWND hDlg, int nIDDlgItem, LPCSTR lpString );

例如:SetDlgItemText(IDC_COMBO2, strLocalIP);

UpdateData(FALSE);

将当前编辑好的数据发送到显示界面上。

UpdateData(TRUE);

获得当前显示界面上的数据

CString StrFilter = _T("配置文件(*.ini)|*.ini|All Files (*.*)|*.*||"); //文件类型过滤器

//弹出文件另存为对话框 

CFileDialog  dlg(FALSE,_T("*.ini"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,StrFilter);

//弹出文件打开对话框

CFileDialog  dlg(TRUE,_T("*.ini"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,StrFilter);

IP Address Control的使用

DWORD dw0; 

m_ipServer.GetAddress(dw0); 

CString str_Server0;

WORD hiWord0=HIWORD(dw0); 

WORD loWord0=LOWORD(dw0); 

BYTE nf10=HIBYTE(hiWord0); 

BYTE nf20=LOBYTE(hiWord0); 

BYTE nf30=HIBYTE(loWord0); 

BYTE nf40=LOBYTE(loWord0); 

str_Server0.Format("%d.%d.%d.%d",nf10,nf20,nf30,nf40);

CString str_Server0_Encode;

str_Server0_Encode = CCode::Encode(str_Server0,key);

::WritePrivateProfileString("ServerInfo","CorrespondAddr",str_Server0_Encode,strFilePath);

CHAR correspondAddr[128];

::GetPrivateProfileString("ServerInfo","CorrespondAddr", "fault",correspondAddr, 128,getPathName);

CString correspondAddr_Decode = CCode::Decode(correspondAddr,key);

str_Server0 = correspondAddr_Decode;

int x10 , x20 , x30 ,x40; 

sscanf_s(str_Server0 , "%d.%d.%d.%d" , &x10 , &x20 , &x30 , &x40);

m_ipServer.SetAddress(x10 , x20 , x30 ,x40 );

将int转换成字符串CString

str.Format(_T("%d"),num);

向文件写入有两种方法

第一种:

WritePrivateProfileStringA(

    _In_opt_ LPCSTR lpAppName,

    _In_opt_ LPCSTR lpKeyName,

    _In_opt_ LPCSTR lpString,

    _In_opt_ LPCSTR lpFileName

    );

举例

CString strCom;

GetDlgItemText(IDC_COMBO2, strCom);

CString strCom_Encode;

strCom_Encode = CCode::Encode(strCom,key);

::WritePrivateProfileString("ServerInfo","ServiceAddr",strCom_Encode,strFilePath);

第2种

file.Open(strFilePath, CFile::modeCreate | CFile::modeWrite | CFile::typeText); 

file.WriteString(line_break);

file.WriteString("\r\n\r\n");

file.Close();

//数据库端口

CHAR DBPort1[128];

CHAR DBPort2[128];

CHAR DBPort3[128];

::GetPrivateProfileString("PlatformDB","DBPort", "fault", DBPort1, 128,getPathName);

::GetPrivateProfileString("TreasureDB","DBPort", "fault", DBPort2, 128,getPathName);

::GetPrivateProfileString("AccountsDB","DBPort", "fault", DBPort3, 128,getPathName);

_tstoi 字符串转换成整型

#include "time.h"

srand((int)time(0));

en[i] = 1+(int)(16.0*rand()/(RAND_MAX+1.0));//生成随机密文(范围可自己调整0-15)

tmps.Format(_T("%x"), tmpi);

整型以十六进制的方式输出字符串