对于GetPrivateProfileString的问题

sunlau29 sunlau29 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
使用GetPrivateProfileString的时候,窗口不能正常显示,会报错关闭,代码如下:


LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
static HDC hdc;
static PAINTSTRUCT ps;
hdc=GetDC(hWnd);
static int PosY=10;
char ch[]="";
LPCSTR str;

switch(uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
return 0;

case WM_CREATE:
GetPrivateProfileString("BackGround","Path",NULL,ch,18,".\\current.ini");

return 0;

case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
SetBkColor(hdc,RGB(255,255,255));
SetTextColor(hdc,RGB(0,0,0));
str=ch;
TextOut(hdc,10,PosY,str,strlen(str));

EndPaint(hWnd,&ps);
return 0;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

ini 文件里面的内容是:

[BackGround]
Path=McDou/McDou.bmp
...全文
评论 15
收藏 已收藏
分享
返回顶部
sunlau29
VC/MFC 16,550 成员 421,606 内容