Old 17th March 2005, 14:29   #1
eleet-2k2
Forum King
 
eleet-2k2's Avatar
 
Join Date: Aug 2001
Location: Mobil Ave.
Posts: 5,381
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!

"Welcome to the Island of people who know too much."..."Did you really think balloons would stop him?!"
See what I'm listening too.
eleet-2k2 is offline   Reply With Quote
Old 17th March 2005, 18:41   #2
dword.dk
Junior Member
 
Join Date: Feb 2005
Posts: 8
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
dword.dk is offline   Reply With Quote
Old 17th March 2005, 21:45   #3
eleet-2k2
Forum King
 
eleet-2k2's Avatar
 
Join Date: Aug 2001
Location: Mobil Ave.
Posts: 5,381
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.

"Welcome to the Island of people who know too much."..."Did you really think balloons would stop him?!"
See what I'm listening too.
eleet-2k2 is offline   Reply With Quote
Old 17th March 2005, 21:54   #4
tracerh
Banned
 
Join Date: Feb 2005
Posts: 84
FindWindow returns the window handle not 1

do this:
code:
if(hwnd_winamp != NULL) // you got winamp window handle ok
tracerh is offline   Reply With Quote
Old 17th March 2005, 22:24   #5
eleet-2k2
Forum King
 
eleet-2k2's Avatar
 
Join Date: Aug 2001
Location: Mobil Ave.
Posts: 5,381
Ah, thanks. It must return 1/True with VB.

"Welcome to the Island of people who know too much."..."Did you really think balloons would stop him?!"
See what I'm listening too.
eleet-2k2 is offline   Reply With Quote
Old 21st March 2005, 08:10   #6
Lord Darius
Senior Member
 
Lord Darius's Avatar
 
Join Date: Jul 2003
Posts: 248
Nope, eleet-2k2, FindWindow returns the handle of the window it just found or NULL if it didn't find anything.
Lord Darius is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump