Problema de error de memoria al usar c para realizar la programación win32 "llamar dinámicamente a DLL"
La ventana correcta (ignore la línea de comentarios) #include?lt; windows.hgt;
#include?lt;tchar.hgt;
// #define?color?RGB(0,144,76)
LRESULT?CALLBACK?WndProc?(HWND,?UINT,?WPARAM,?LPARAM)?;?
void? );
INT32?iYX[2];
const?int WX=800;
const?int WY=600;
DWORD g_tPre=0, g_tNow=0;
HFONT hFont;
HPEN hPen;
INT32 i[2]={GetSystemMetrics?(? SM_CXSCREEN? )/2, GetSystemMetrics?(?SM_CYSCREEN?)/2};
HPEN hPenOld;
HWND hwnd?;
MSG msg={0 }? ;
WNDCLASS wndclass?;
HDC hdc?;?
PAINTSTRUCT ps?;
RECT rect?;
HDC hdc?; p>
PAINTSTRUCT paintStruct;
HBITMAP g_hBitmap=NULL;?
HDC g_mdc=NULL
BOOL id= false;
PUNTO?p;
int?WINAPI?WinMain?(HINSTANCE?hInstance,?HINSTANCE?hPrevInstance,PSTR?szCmdLine,?int?iCmdShow)
{
?static?TCHAR?szAppName[] =?TEXT?("HelloWin")?; wndclass.style =?CS_HREDRAW?|?CS_VREDRAW?;?
?wndclass.cbClsExtra =?0?;?
?wndclass.cbWndExtra =?0?;
?wndclass.hInstance =?hInstance?;
? wndclass.hIcon =?LoadIcon?(NULL,?IDI_APPLICATION)?;?
?wndclass.hCursor =?LoadCursor?(NULL,?IDC_ARROW)?;?
?wndclass. hbrBackground =?(HBRUSH)?GetStockObject?(WHITE_BRUSH)?;?
?wndclass.lpszMenuName =?NULL?;
?wndclass.lpszClassN
ame =?szAppName?;
?wndclass.hIcon =(HICON)::LoadImage(NULL, "icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE);
if?(!RegisterClass?(amp; wndclass))
{?
MessageBox?(?NULL,?TEXT?("¡Ocurrió un error! ¡El programa requiere sistema Windows! ") ,?szAppName,?MB_ICONERROR)?;
return?0?;?
}
//SetCursorPos(GetSystemMetrics?(?SM_CXSCREEN?) /2 , GetSystemMetrics?(?SM_CYSCREEN?)/2);
hwnd?=CreateWindow
(?szAppName,?TEXT?(""),
WS_POPUP ?,
(GetSystemMetrics?(?SM_CXSCREEN?)/2)-150, (GetSystemMetrics?(?SM_CYSCREEN?)/2)-75,
300, 150,
p>NULL, ?NULL, ?hInstance, NULL);?
hdc?=GetDC(hwnd);
ShowWindow?(hwnd, ?iCmdShow )?;
UpdateWindow?(hwnd)?;?
while(?msg.message?!=?WM_QUIT?)
{
if (?PeekMessage(?amp;msg,?0,?0,?0,?PM_REMOVE?)?)
{
TranslateMessage(?amp;msg?
p>DispatchMessage(?amp;msg?
}
else
{
g_tNow=?GetTickCount( );?
if(g_tNow-g_tPre?gt;=?100)
show();
}
}
return?msg.wParam?;
}
LRESULT?CALLBACK?WndProc?(HWND?hwnd,?UINT?message, ?WPARAM?wParam,? LPARAM?lParam)
{
cambiar?(mensaje)
{?
caso?WM_CREATE: ?
retorno?0?;
descanso;
caseWM_DESTROY:?
PostQuitMessage?(0)?;
return?0 ;
descanso;
?case?WM_KEYDOWN:
si?(wParam?=
=?VK_ESCAPE)
DestroyWindow(hwnd);
case?WM_LBUTTONDOWN:
DestroyWindow(hwnd);
¿retorno?0? ;
descanso;
valor predeterminado:
retorno?DefWindowProc(?hwnd,?message,?wParam,?lParam?);
}?
retorno?0?;
}
void?show?()
{
GetCursorPos(amp;p);
g_tPre?=?GetTickCount();?
DeleteObject?(?hFont?);
}