Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8112503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:31:24+00:00 2026-06-06T02:31:24+00:00

The following code is taken from here . I removed all Windows NT part

  • 0

The following code is taken from here. I removed all Windows NT part as I am working on Windows 7.

I copied this code and run in visual studio 2010 (New project-> VC++->CLR->CLR Console… ). But it is giving lots of unresolved extern ‘c’ errors as listed below the code. What wrong I have committed?

#define STRICT  1 

#include <windows.h>
#include <iostream>
using namespace std;

BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) {
DWORD dwThreadId, dwProcessId;
HINSTANCE hInstance;
char String[255];
HANDLE hProcess;
if (!hWnd)
return TRUE;        // Not a window
if (!::IsWindowVisible(hWnd))
return TRUE;        // Not visible
if (!SendMessage(hWnd, WM_GETTEXT, sizeof(String), (LPARAM)String))
return TRUE;        // No window title
hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
dwThreadId = GetWindowThreadProcessId(hWnd, &dwProcessId);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
cout << hWnd << ' ' << dwProcessId << '\t' << String << '\t';
cout << "(None)\n";
CloseHandle(hProcess);
return TRUE;
}

int main(int argc, char *argv[], char *envp[]) {
EnumWindows(EnumWindowsProc, NULL);
return 0;
}

This is giving following Errors(and other similar unresolved extern C errors)

 1>wndowfind.obj : error LNK2028: unresolved token (0A000342) "extern "C" int __stdcall       
 EnumWindows(int (__stdcall*)(struct HWND__ *,long),long)"     3
 (?EnumWindows@@$$J18YGHP6GHPAUHWND__@@J@ZJ@Z) referenced in function "int __cdecl 
 main(int,char * * const,char * * const)" (?main@@$$HYAHHQAPAD0@Z)

 1>wndowfind.obj : error LNK2028: unresolved token (0A000346) "extern "C" unsigned long  
 __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)"    
 (?GetWindowThreadProcessId@@$$J18YGKPAUHWND__@@PAK@Z) referenced in function "int __stdcall 
 EnumWindowsProc(struct HWND__ *,long)" (?EnumWindowsProc@@$$FYGHPAUHWND__@@J@Z)

 1>wndowfind.obj : error LNK2028: unresolved token (0A000347) "extern "C" long __stdcall 
 GetWindowLongW(struct HWND__ *,int)" (?GetWindowLongW@@$$J18YGJPAUHWND__@@H@Z) referenced in 
 function "int __stdcall EnumWindowsProc(struct HWND__ *,long)" 
 (?EnumWindowsProc@@$$FYGHPAUHWND__@@J@Z)

 1>wndowfind.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall  
 EnumWindows(int (__stdcall*)(struct HWND__ *,long),long)" 
 (?EnumWindows@@$$J18YGHP6GHPAUHWND__@@J@ZJ@Z) referenced in function "int __cdecl 
 main(int,char * * const,char * * const)" (?main@@$$HYAHHQAPAD0@Z)

 1>c:\users\afnan\documents\visual studio 2010\Projects\wndowfind\Debug\wndowfind.exe : fatal 
 error LNK1120: 10 unresolved externals
 1>
 1>Build FAILED.

UPDATED

By including the libraries (as suggested in the answers), I was able to run the program successfully. But I am not able to understand why only first character of string is printing not the complete one, as can be seen in the output:

00010060 2652   S       (None)
002502B2 5820   C       (None)
00090402 5160   w       (None)
00050392 5160   w       (None)
00060292 3520   F       (None)
000C02BA 3520   M       (None)
0001021A 3736   E       (None)
00040018 896    I       (None)
00010170 3580   A       (None)
0002003E 2684   D       (None)
00030316 4956   N       (None)
000202DE 3736   D       (None)
0001031E 2652   S       (None)
000100EA 2652   P       (None) 

In the output above, S is actually “start”, C is “console” etc I confirmed through spy++ tool.
How can I print the complete string instead of just first character?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:31:28+00:00Added an answer on June 6, 2026 at 2:31 am

    CLR projects by default do not include the standard Windows libraries, such as user32.lib.

    Edit your project properties, find the Linker Inputs option, and add kernel32.lib user32.lib advapi32.lib which are the usual libraries needed by Win32 code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible to do the following in ExpressionEngine: (code taken from here )
The following code (taken from here ): int* ptr = int(); compiles in Visual
How should I understand $(select option:selected) in the following code ? (taken from here
Hey all, the following is a snippet of code taken from the unix ptx
I'm using the following code on my iPhone app, taken from here to extract
This may well have come up before but the following code is taken from
I have the following piece of code taken from the PHP manual on the
I have the following piece of code that is taken from a mock exam
i have the following code, taken partly from a Red Black Tree Java implementation.
Just run into a tricky NSFetchedResultsController problem. The following code works fine in all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.