Showing posts with label api. Show all posts
Showing posts with label api. Show all posts

Friday, September 20, 2013

Generate Lib From DLL

Introduction
To avoid installing and fighting against MSYS and Cygwin, you can just extract exported symbols from libvlc.dll to generate a .lib (libvlc.lib) and link your program against it.

Open Visual Studio Command Prompt
It can be found within the Visual Studio Tools menu entry:
Start / Program Files / Microsoft Visual Studio / Visual Studio Tools / Visual Studio Command Prompt.

Extract Symbols
Within the command prompt type:
dumpbin /exports "C:\Program Files\VideoLAN\VLC\libvlc.dll" > "C:\Program Files\VideoLAN\VLC\libvlc.def"
Edit the libvlc.def file and modify it to get something like this:
EXPORTS
libvlc_add_intf
libvlc_audio_get_channel
libvlc_audio_get_mute
libvlc_audio_get_track
libvlc_audio_get_track_count
libvlc_audio_get_track_description
libvlc_audio_get_volume
...
Generate the .lib
Still within the command prompt type:
lib /def:"C:\Program Files\VideoLAN\VLC\libvlc.def" /out:"C:\Program Files\VideoLAN\VLC\libvlc.lib" /machine:x86
Of course, you'll need to adapt the path according to your configuration.

Source
Generate Lib From DLL

Wednesday, June 19, 2013

Windows API: The relationship between Process, Handle and Windows

1)
HAVE: Process ID, NEED: Process handle
Solution: 
OpenProcess()

2)
HAVE: Process handle, NEED: Process ID
Solution: GetProcessId()

3)
HAVE: Window handle, NEED: Process ID
Solution: GetWindowThreadProcessId()

4)
HAVE: Window handle, NEED: Process handle
Solution: Use 3) and then 1)

5)
HAVE: Process ID, NEED: Window handle
Solution: EnumWindows(), then in the callback function do 3) and check if it matches your process ID.

6)
HAVE: Process handle, NEED: Window handle
Solution: 2) and then 5)