史上最优美的轻音乐mp3:vc++字符串变量如何转变成字符变量?

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 01:00:02
::RegSetValueEx(hKey, *name, 0, REG_SZ, (BYTE*)value, strlen(value));
其中的value好像必须得是字符变量,要不然在注册表里就显示成不可知的乱码?
可是在GetDlgItem( IDC_EDITvalue)->GetWindowText( *value )(这里是mfc里的一个框)必须是字符串变量?
应该怎么处理?

呵呵!方法很多啊!

CString s;
char *a =(char*)s.GetBuffer(s.GetLength());
s.ReleaseBuffer();

CString s;
char *a;
strcpy(a, s);

CString s;
char *p;
p=(char*)(LPCTSTR)s;

CString s;
char *p;
p= (LPTSTR)(LPCTSTR)s;

你的函数是BYTE??怎么转应该知道吧!

我现在用最后一个!以前上学用第一种,后来单位的虾说用最用一种

将CString转换。
例如:
CString strValue;
GetDlgItem(IDC_EDITValue)->GetWindowText(strValue);
int iLength = strValue.GetLength();
::RegSetValueEx(hKey, *name, 0, REG_SZ,
strValue.GetBuffer(iLength), iLength);