对于GetPrivateProfileString的问题
使用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