Winamp Control
Hej,jeg har lavet et Winamp Control ud fra en guide jeg fandt et eller andet sted (kan ikke huske hvor).
Desværre virker det ikke :(
Jeg får en exception (den i koden nedenunder) fordi den ikke kan finde winduet.. "Winamp v1.x"
Men hvad hedder vinduet så??
Her er koden:
-----------------------------
public Control()
{
// Try to find a Winamp window.
WINDOW_HANDLER = FindWindow("Winamp v1.x",null);
if(WINDOW_HANDLER == 0)
{
// Throw exception if we can not find a Winamp window.
throw new System.Exception("Could not find a Winamp window!");
}
}
/// <summary>
/// The value returned is a 32-bit value representing the window.
/// If no window is found, the return value will be 0 and we will
/// throw an exception. Since the method mentioned is a native API
/// method in the file user32.dll, we somehow need to declare a method
/// as having an implementation from a DLL export. This is where the
/// DllImport-attribute and the extern keyword is used.
/// </summary>
[System.Runtime.InteropServices.DllImport("user32.dll",EntryPoint="SendMessage")]
private static extern int SendMessage(int _WindowHandler, int _WM_USER, int _data, int _id);
/// <summary>
/// The first argument is of course the file, in which we expect to
/// find the method. The second argument, the entrypoint, is the actual
/// name of the method. This argument only has to be passed if we want
/// to name our extern C# method to something else. This is not the case,
/// and the argument is shown mostly for convinience. Note that extern
/// methods have to be declared as static and we must use the keyword
/// extern.
/// </summary>
[System.Runtime.InteropServices.DllImport("user32.dll",EntryPoint="FindWindow")]
private static extern int FindWindow(string _ClassName, string _WindowName);
-----------------------------
