KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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
Tags (comma-separated)
Save Edits
Cancel