Question

After some struggling with an app that displays the time in a label when a button is pressed, it have finally come down to a linker error.

The line of code wich is causing this is:

_wstrdate(dateStr);

The faults is:

error LNK2019: unresolved external symbol _wstrdate referenced in function "long __cdecl WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YAJPAUHWND__@@IIJ@Z)
fatal error LNK1120: 1 unresolved externals

I was told to post my WNDPROC & linker settings here:

  LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

static HWND hButton;
static HWND hLabel;
static SHACTIVATEINFO s_sai;

switch (message) 
{
    case WM_COMMAND:
        wmId    = LOWORD(wParam); 
        wmEvent = HIWORD(wParam); 
        // Parse the menu selections:
        switch (wmId)
        {
            case IDM_HELP_ABOUT:
                DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
                break;
 #ifdef WIN32_PLATFORM_PSPC
            case IDM_OK:
                SendMessage (hWnd, WM_CLOSE, 0, 0);             
                break;

            case 1001:
            {



                _wstrdate(dateStr);

                SetDlgItemTextW(hWnd, 1003, dateStr);


                break;
            }

#endif // WIN32_PLATFORM_PSPC
            default:
                return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_CREATE:
#ifdef SHELL_AYGSHELL
        SHMENUBARINFO mbi;

        memset(&mbi, 0, sizeof(SHMENUBARINFO));
        mbi.cbSize     = sizeof(SHMENUBARINFO);
        mbi.hwndParent = hWnd;
        mbi.nToolBarId = IDR_MENU;
        mbi.hInstRes   = g_hInst;

        hButton = CreateWindow( L"button",L"Time",
            WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
            100,200,
            50,20,
            hWnd, (HMENU) MEDDELANDEBUTTON_ID,
             NULL, NULL);



        hLabel = CreateWindowW(L"STATIC",L"Time",
        WS_VISIBLE | WS_CHILD | SS_RIGHT,
        10,200,75,35,hWnd, (HMENU)1003, NULL, NULL);





        if (!SHCreateMenuBar(&mbi)) 
        {
            g_hWndMenuBar = NULL;
        }
        else
        {
            g_hWndMenuBar = mbi.hwndMB;
        }

        // Initialize the shell activate info structure
        memset(&s_sai, 0, sizeof (s_sai));
        s_sai.cbSize = sizeof (s_sai);
#endif // SHELL_AYGSHELL
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);

        // TODO: Add any drawing code here...

        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
 #ifdef SHELL_AYGSHELL
        CommandBar_Destroy(g_hWndMenuBar);
 #endif // SHELL_AYGSHELL
        PostQuitMessage(0);
        break;

    case WM_ACTIVATE:
        // Notify shell of our activate message
        SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
        break;
    case WM_SETTINGCHANGE:
        SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
        break;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

Also here is my linker options: (Standard visualstudio 2008)

/OUT:"Pocket PC 2003 (ARMV4)  \Debug/c++pocketpc.exe" /INCREMENTAL /NOLOGO /MANIFEST:NO /NODEFAULTLIB:"oldnames.lib" /DEBUG /PDB:"Pocket PC 2003 (ARMV4)\Debug/c++pocketpc.pdb" /STACK:65536,4096 /DYNAMICBASE:NO /ERRORREPORT:PROMPT coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib

No correct solution

OTHER TIPS

From the Microsoft page on Control.WinProc,

Platform

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

So, you are covered there.

However, under .NET Framework Security, I see

  • SecurityPermission for inheriting classes to call unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

  • SecurityPermission for the immediate caller to call unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

So, it looks like you may have to wrap your code in an unsafe block. I take it you are doing that already.

The info I found on _wstrdate has this in the code example:

// Note: _strdate is deprecated; consider using _strdate_s instead

The .NET Framework Equivalent section gives a link to System::DateTime::Parse, so you may get good results by trying it.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top