title: vs 2010: error LNK2028: unresolved token (0A000342) "extern "C" int __stdcall
body: <p>The following code is taken from <a href="http://simplesamples.info/Windows/EnumWindows.php" rel="noreferrer">here</a>. I removed all Windows NT part as I am working on Windows 7. </p>
  
  <p>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?  </p>
  
  <pre><code>#define STRICT  1 
  
  #include &lt;windows.h&gt;
  #include &lt;iostream&gt;
  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, &amp;dwProcessId);
  hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
  cout &lt;&lt; hWnd &lt;&lt; ' ' &lt;&lt; dwProcessId &lt;&lt; '\t' &lt;&lt; String &lt;&lt; '\t';
  cout &lt;&lt; "(None)\n";
  CloseHandle(hProcess);
  return TRUE;
  }
  
  int main(int argc, char *argv[], char *envp[]) {
  EnumWindows(EnumWindowsProc, NULL);
  return 0;
  }
  </code></pre>
  
  <p><strong>This is giving following Errors(and other similar unresolved extern C errors)</strong> </p>
  
  <pre><code> 1&gt;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&gt;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&gt;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&gt;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&gt;c:\users\afnan\documents\visual studio 2010\Projects\wndowfind\Debug\wndowfind.exe : fatal 
   error LNK1120: 10 unresolved externals
   1&gt;
   1&gt;Build FAILED.
  </code></pre>
  
  <p><strong>UPDATED</strong></p>
  
  <p>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:</p>
  
  <pre><code>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) 
  </code></pre>
  
  <p>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?    </p>