The Winamp Remote Control suite
a remote control client and plugin for Winamp 2.x, 5.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gen_plugin.cpp
Go to the documentation of this file.
1 /*
2 winamp remote control suite ŠPatrick Michael Martin 2000, 2001, 2012
3 
4 Copyright (C) 2000,2001,2012 Patrick M. Martin
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 Patrick M. Martin may be reached by email at patrickmmartin@gmail.com.
21 */
22 
23 #pragma hdrstop
24 #include <registry.hpp> // TRegistry
25 #include "VersionInfoU.h" // TVersionInfo
26 #include "gen_plugin.h" // winamp plugin declarations
27 #include "ServerDLLF.h" // for main form
28 #include "ConfigDLLF.h" // for config form
29 #include "waint.h" // extern HWND variable
30 // buffer for the control structure
31 
32 char VerString[MAX_PATH + 1];
33 
35 {
36  GPPHDR_VER,
37  VerString,
38  init,
39  config,
40  quit,
41  0,
42  0
43 };
44 
45 
46 void config();
47 void quit();
48 int init();
49 
50 
51 
52 extern "C" winampGeneralPurposePlugin * __declspec(dllexport) __stdcall winampGetGeneralPurposePlugin()
53 {
54 
55  TModuleVersionInfo * VI;
56  char FileName[MAX_PATH + 1];
57 
58  GetModuleFileName(HInstance, FileName, MAX_PATH);
59  VI = new TModuleVersionInfo(FileName);
60 
61  strncpy(VerString,
62  AnsiString("Winamp Remote Control Suite " + VI->FileVersion).c_str(),
63  MAX_PATH);
64 
65  delete VI;
66 
67  OutputDebugString("RPCInterface get config");
68  return &plugin;
69 }
70 
71 
72 
73 void config(void)
74 {
75 
76  OutputDebugString("RPCInterface config");
77  TConfigForm *frmConfig = new TConfigForm(NULL);
78  try
79  {
80  frmConfig->ShowModal();
81  }
82  __finally
83  {
84  delete frmConfig;
85  }
86 }
87 
88 
89 
90 void quit(void)
91 {
92  OutputDebugString("RPCInterface quit");
93  if (frmPluginMain != NULL)
94  {
95  try
96  {
97  frmPluginMain->Close();
98  delete frmPluginMain;
99  }
100  __finally
101  {
102  frmPluginMain = NULL;
103  }
104  }
105 }
106 
107 
108 
109 int init()
110 {
111  OutputDebugString("RPCInterface init");
112 TRegistry * reg;
113 AnsiString str;
114  if (frmPluginMain == NULL)
115  {
116  try
117  {
118  // pass on the provided parameters
119  // this gets better behaviour for VCL dlls
120  Application->Handle = plugin.hwndParent;
121  frmPluginMain = new TfrmPluginMain(Application);
122  try
123  {
124  // set parent handle
125  reg = new TRegistry();
126  reg->OpenKey("software\\PMMSoft\\Winamp controller\\server settings", true);
127  str = reg->ReadString("Visible");
128  if (str.LowerCase() == "true")
129  frmPluginMain->Show();
130  }
131  __finally
132  {
133  delete reg;
134  }
135  }
136  catch (...)
137  {
138  delete frmPluginMain;
139  frmPluginMain = NULL;
140  }
141  }
142  return 0;
143 }