Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   Winamp Development (http://forums.winamp.com/forumdisplay.php?f=14)
-   -   C++ API Call help (http://forums.winamp.com/showthread.php?t=210683)

eleet-2k2 17th March 2005 14:29

C++ API Call help
 
Hi guys, long time no post. :/

I was wondering if someone would be kind enough to offer me the corresponding C++ code for the following VB API calls. It would be very much appreciated.

code:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SendMessageA Lib "user32" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SendMessageCDS Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As COPYDATASTRUCT) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const WM_USER = &H400
Public Const WM_WA_IPC = WM_USER
Public Const WM_COPYDATA = &H4A
Public Const WM_COMMAND = &H111

Public hwnd_winamp As Long
Public hwnd_eq As Long
Public hwnd_playlist As Long
Public Const IPC_GETWND_EQ = 0
Public Const IPC_GETWND_PE = 1
Public Const IPC_GETWND = 260

Public Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As String
End Type



Would you also be able to show an example API call or two so I can port my code accordingly?

Thanks for any and all help! :)

dword.dk 17th March 2005 18:41

For the functions just #include <windows.h>. Then use them directly e.g. as:
code:
LRESULT result = SendMessage(hWnd, uMsg, wParam, lParam);

The constants you listed (and also the struct I think) are defined in "wa_ipc.h" of the Winamp SDK, and the 3 global variables you'll have to make and assign to yourself. HtH

-Christian Larsen

eleet-2k2 17th March 2005 21:45

I have the following code:
code:
HWND hwnd_winamp;

int FindWinamp() {
//Find winamp window
//Returns 1 if winamp is open, 0 if not
hwnd_winamp = FindWindow("Winamp v1.x", 0);

if (hwnd_winamp == 1) {
return 1;
} else {
return 0;
}
}

I'm getting an error with the if() statement that C++ cannot compare a pointer and an integer. How do I determine the value that hwnd_winamp points to? (I haven't coded C++ in a while so I'm a bit rusty).

Thanks in advance.

tracerh 17th March 2005 21:54

FindWindow returns the window handle not 1

do this:
code:
if(hwnd_winamp != NULL) // you got winamp window handle ok

eleet-2k2 17th March 2005 22:24

Ah, thanks. It must return 1/True with VB.

Lord Darius 21st March 2005 08:10

Nope, eleet-2k2, FindWindow returns the handle of the window it just found or NULL if it didn't find anything.


All times are GMT. The time now is 20:58.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.