J
J
Jomm2021-07-17 20:42:46
Windows Forms
Jomm, 2021-07-17 20:42:46

How to call FindWindowA function in Windows Forms?

I wrote a small console program, it had these lines:

hwnd = FindWindowA(NULL, "Notepad");
GetWindowThreadProcessId(hwnd, &procid);

And I decided to transfer the application from the console to Windows Forms, but it gives me errors:
unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" ([email protected]@[email protected]@[email protected])
unresolved external symbol "extern "C" unsigned long __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)" ([email protected]@[email protected]@[email protected])

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jomm, 2021-07-18
@Jomm

1. Right click on project -- > Properties --> Configuration Properties --> Linker --> Input
2. Select the 'Additional Dependencies" property node and then Click the on the 3 dotted (...) button
3. Then on the 'Additional Dependencies' popup, input "user32.lib" on the top textbox and click on 'Ok' button
4. Click on 'Apply' button and re-compile your application. .............. the linker errors are gone!

A
Alexander Ananiev, 2021-07-17
@SaNNy32

https://docs.microsoft.com/en-us/dotnet/standard/n...
https://pinvoke.net/default.aspx/user32/FindWindow.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question