Home > Back-end >  Vs compiler under load WNTDLL. PDB, debugging after DialogBox wWinMain function automatically when t
Vs compiler under load WNTDLL. PDB, debugging after DialogBox wWinMain function automatically when t

Time:09-17

I check it on the website of the modified this method doesn't work, into a small white followed this website https://www.bilibili.com/video/BV1NJ411b7ZV? to go to school P=83, the program is as follows, could you tell me how to modify the
# include
# include "resource. H"
Void FillListBox (HWND hwndList)
{
//TCHAR szBuf [1024].//use the stack
TCHAR * pVarName;//the heap
//LPVOID pVName;//the heap
TCHAR * pVarBlock;
PVarBeg TCHAR * and * pVarEnd;
Int iLength;
PVarBlock=GetEnvironmentStrings ();
While (* pVarBlock)
{
If (* pVarBlock!='=')
{
PVarBeg=pVarBlock;
While (* pVarBlock++!='=');
PVarEnd=pVarBlock - 1;
ILength=pVarEnd - pVarBeg;
//use the stack
/* ZeroMemory (szBuf, 1024);
CopyMemory (szBuf, pVarBeg iLength * sizeof (TCHAR));
SendMessage (hwndList LB_ADDSTRING, 0, (LPARAM) szBuf); */
//the heap
PVarName=(TCHAR *) calloc (iLength + 1, sizeof (TCHAR));
PVarName=(TCHAR *) malloc sizeof ((iLength + 1) * (TCHAR)); ZeroMemory (pVarName, ((iLength + 1) * sizeof (TCHAR)));
CopyMemory (pVarName pVarBeg, iLength * sizeof (TCHAR));
SendMessage (hwndList LB_ADDSTRING, 0, (LPARAM) pVarName);
Free (pVarName);

//use HeapAlloc
/* pVName=HeapAlloc (GetProcessHeap (), 0, sizeof (iLength + 1) * (TCHAR));
ZeroMemory (pVName, sizeof (iLength + 1) * (TCHAR));
CopyMemory (pVName, pVarBeg iLength * sizeof (TCHAR));
SendMessage (hwndList LB_ADDSTRING, 0, (LPARAM) pVName);
HeapFree (GetProcessHeap (), 0, pVName); */
}
While (* pVarBlock++!='\ 0');
}
FreeEnvironmentStrings (pVarBlock);
}
INT_PTR CALLBACK MainDlgProc (HWND hDlg, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM)
{
BOOL bRet=TRUE;
Int iIndex iLength;//choose to list is which one, and how long it is
PVarName TCHAR * and * pVarValue;
The switch (uMsg)
{
Case WM_INITDIALOG:
FillListBox (GetDlgItem (hDlg, IDC_LIST1));
break;
Case WM_COMMAND:
If (LOWORD (wParam)==IDC_LIST1 & amp; & HIWORD (wParam)==LBN_SELCHANGE)
{
IIndex=SendMessage (GetDlgItem (hDlg, IDC_LIST1), LB_GETCURSEL, 0, 0).
ILength=SendMessage (GetDlgItem (hDlg, IDC_LIST1), LB_GETTEXTLEN, iIndex, 0) + 1;
PVarName=(TCHAR *) calloc (iLength, sizeof (TCHAR));
SendMessage (GetDlgItem (hDlg, IDC_LIST1), LB_GETTEXT, iIndex, (LPARAM) pVarName);
ILength=GetEnvironmentVariable (pVarName, NULL, 0);
PVarValue=https://bbs.csdn.net/topics/(TCHAR *) calloc (iLength, sizeof (TCHAR));
The GetEnvironmentVariable (pVarName, pVarValue iLength);
SetWindowText (GetDlgItem (hDlg, IDC_LIST1), pVarValue);
Free (pVarName);
Free (pVarValue);
}
break;
Case WM_CLOSE:
EndDialog (hDlg, 0);
break;
Default:
BRet=FALSE;
break;
}
Return bRet.
}
Int APIENTRY wWinMain (HINSTANCE HINSTANCE,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
Int nCmdShow)
{
DialogBox (hInstance, MAKEINTRESOURCE (IDD_DIALOG1), NULL, MainDlgProc);
return 0;
}
  • Related