api_application.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. // ----------------------------------------------------------------------------
  2. // Generated by InterfaceFactory [Wed May 07 00:55:56 2003]
  3. //
  4. // File : api_application.h
  5. // Class : api_application
  6. // class layer : Dispatchable Interface
  7. // ----------------------------------------------------------------------------
  8. #ifndef __API_APPLICATION_H
  9. #define __API_APPLICATION_H
  10. #include <bfc/dispatch.h>
  11. #include <bfc/platform/guid.h>
  12. #include <bfc/platform/platform.h>
  13. #ifdef _WIN32
  14. #include "ifc_messageprocessor.h"
  15. #endif
  16. // ----------------------------------------------------------------------------
  17. enum
  18. {
  19. API_APPLICATION_SUCCESS = 0,
  20. API_APPLICATION_FAILURE = 1,
  21. };
  22. enum
  23. {
  24. TRANSLATE_MODE_NORMAL = 0,
  25. TRANSLATE_MODE_GLOBAL = 1,
  26. TRANSLATE_MODE_CHILD = 2,
  27. };
  28. class NOVTABLE api_application: public Dispatchable
  29. {
  30. protected:
  31. api_application() {}
  32. ~api_application() {}
  33. public:
  34. const wchar_t *main_getAppName(); // returns (e.g.) "Winamp"
  35. const wchar_t *main_getVersionString(); // returns (e.g.) "Winamp 5.12"
  36. const wchar_t *main_getVersionNumString(); // returns (e.g.) "5.12"
  37. unsigned int main_getBuildNumber(); // returns (e.g.) 666
  38. GUID main_getGUID();
  39. #ifdef _WIN32
  40. HANDLE main_getMainThreadHandle(); // This actually gives you a DuplicateHandle, so call CloseHandle() when you are done.
  41. HINSTANCE main_gethInstance();
  42. #endif // !_WIN32
  43. const wchar_t *main_getCommandLine();
  44. void main_shutdown( int deferred = TRUE );
  45. void main_cancelShutdown();
  46. int main_isShuttingDown();
  47. const wchar_t *path_getAppPath();
  48. const wchar_t *path_getUserSettingsPath();
  49. // added for 5.58+ so gen_ff can fill @SKINSPATH@ in scripts correctly
  50. const wchar_t *path_getSkinSettingsPath();
  51. int app_getInitCount();
  52. intptr_t app_messageLoopStep();
  53. #ifdef _WIN32
  54. void app_addMessageProcessor( ifc_messageprocessor *processor );
  55. void app_removeMessageProcessor( ifc_messageprocessor *processor );
  56. /* accelerators are 5.53+ */
  57. void app_addAccelerators( HWND hwnd, HACCEL *phAccel, INT cAccel, UINT translateMode );
  58. void app_removeAccelerators( HWND hwnd );
  59. bool app_translateAccelerators( MSG *msg );
  60. int app_getAccelerators( HWND hwnd, HACCEL *phAccel, INT cchAccelMax, BOOL bGlobal ); // phAccel == NULL && cchAccelMax == 0 -> returns accels count
  61. /* register window as part of winamp global group (5.54+) */
  62. void app_registerGlobalWindow( HWND hwnd );
  63. void app_unregisterGlobalWindow( HWND hwnd );
  64. /* 5.58 + */
  65. bool DirectMouseWheel_RegisterSkipClass( ATOM klass );
  66. bool DirectMouseWheel_UnregisterSkipClass( ATOM klass );
  67. bool DirectMouseWheel_EnableConvertToMouseWheel( HWND hwnd, BOOL enable ); // !!! must be disabled before window destroyed !!!
  68. /* 5.64 + */
  69. BOOL DirectMouseWheel_ProcessDialogMessage( HWND hwnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam, const int controls[], int controlslen );
  70. /* 5.61 + */
  71. void ActiveDialog_Register( HWND hwnd );
  72. void ActiveDialog_Unregister( HWND hwnd );
  73. HWND ActiveDialog_Get();
  74. /* 5.64 + */
  75. const wchar_t *getATFString(); // returns the current ATF formatting string
  76. /* 5.66 + */
  77. // used for dpi scaling so we're consistent in usage throughout the UI, etc
  78. int getScaleX( int x );
  79. int getScaleY( int y );
  80. #endif // !_WIN32
  81. /*
  82. note: on windows, these two functions DON'T call Set/GetCurrentDirectory, Winamp maintains it's own path
  83. because calling SetCurrentDirectory locks the folder
  84. Added for 5.34
  85. */
  86. const wchar_t *path_getWorkingPath(); // useful to call for populating lpstrInitialDir in GetOpenFileName
  87. void path_setWorkingPath(const wchar_t *newPath); // useful to call for populating lpstrInitialDir in GetOpenFileName
  88. /*
  89. The following three function return you unique IDs you can use if you need
  90. They are created anonymously, so information cannot be tracked back to a specific person
  91. The main reason for their existence is that a few third party libraries require them
  92. and some online media providers require this info for billing.
  93. You can call this functions with a pointer to any 16 byte data structure cast to a GUID *
  94. Added for 5.35
  95. */
  96. // returns an ID unique to this computer, but not unique to the logged in user (two windows accts would share this ID)
  97. int GetMachineID( GUID *id );
  98. // returns an ID unique to this user. Another user logged in to the computer will have a different ID
  99. // note that if Winamp was installed with "shared settings", the IDs of multiple users will probably be identical
  100. // as we're just storing it in winamp.ini for now
  101. int GetUserID( GUID *id );
  102. // returns a unique ID for this session. Generated on the fly the first time someone calls this function
  103. int GetSessionID( GUID *id );
  104. /* 5.54 + */
  105. size_t AllocateThreadStorage(); // returns an index, -1 for error
  106. void *GetThreadStorage(size_t index);
  107. void SetThreadStorage(size_t index, void *value);
  108. protected:
  109. enum
  110. {
  111. API_APPLICATION_MAIN_GETAPPNAME = 10,
  112. API_APPLICATION_MAIN_GETVERSIONSTRING = 20,
  113. API_APPLICATION_MAIN_GETVERSIONSTRING2 = 21,
  114. API_APPLICATION_MAIN_GETBUILDNUMBER = 30,
  115. API_APPLICATION_MAIN_GETGUID = 40,
  116. API_APPLICATION_MAIN_GETMAINTHREADHANDLE = 50,
  117. API_APPLICATION_MAIN_GETHINSTANCE = 60,
  118. API_APPLICATION_MAIN_GETCOMMANDLINE = 70,
  119. API_APPLICATION_MAIN_SHUTDOWN = 80,
  120. API_APPLICATION_MAIN_CANCELSHUTDOWN = 90,
  121. API_APPLICATION_MAIN_ISSHUTTINGDOWN = 100,
  122. API_APPLICATION_PATH_GETAPPPATH = 110,
  123. API_APPLICATION_PATH_GETUSERSETTINGSPATH = 120,
  124. API_APPLICATION_APP_GETINITCOUNT = 130,
  125. API_APPLICATION_APP_MESSAGELOOPSTEP = 140,
  126. API_APPLICATION_APP_ADDMESSAGEPROCESSOR = 150,
  127. API_APPLICATION_APP_REMOVEMESSAGEPROCESSOR = 160,
  128. API_APPLICATION_APP_ADDMODELESSDIALOG = 170,
  129. API_APPLICATION_APP_REMOVEMODELESSDIALOG = 180,
  130. API_APPLICATION_PATH_GETWORKINGPATH = 190,
  131. API_APPLICATION_PATH_SETWORKINGPATH = 200,
  132. API_APPLICATION_GETMACHINEID = 210,
  133. API_APPLICATION_GETUSERID = 220,
  134. API_APPLICATION_GETSESSIONID = 230,
  135. API_APPLICATION_APP_ADDACCELERATORS = 240,
  136. API_APPLICATION_APP_REMOVEACCELERATORS = 250,
  137. API_APPLICATION_APP_TRANSLATEACCELERATORS = 260,
  138. API_APPLICATION_APP_GETACCELERATORS = 270,
  139. API_APPLICATION_APP_REGISTERGLOBALWINDOW = 280,
  140. API_APPLICATION_APP_UNREGISTERGLOBALWINDOW = 290,
  141. API_APPLICATION_ALLOCATETHREADSTORAGE = 300,
  142. API_APPLICATION_GETTHREADSTORAGE = 310,
  143. API_APPLICATION_SETTHREADSTORAGE = 320,
  144. API_APPLICATION_PATH_GETSKINSETTINGSPATH = 330,
  145. API_APPLICATION_DIRECTMOUSEWHEEL_REGISTERSKIPCLASS = 340,
  146. API_APPLICATION_DIRECTMOUSEWHEEL_UNREGISTERSKIPCLASS = 350,
  147. API_APPLICATION_DIRECTMOUSEWHEEL_ENABLECONVERTTOMOUSEWHEEL = 360,
  148. API_APPLICATION_DIRECTMOUSEWHEEL_PROCESSDIALOGMESSAGE = 365,
  149. API_APPLICATION_ACTIVEDIALOG_REGISTER = 370,
  150. API_APPLICATION_ACTIVEDIALOG_UNREGISTER = 380,
  151. API_APPLICATION_ACTIVEDIALOG_GET = 390,
  152. API_APPLICATION_GETATFSTRING = 400,
  153. API_APPLICATION_GETSCALEX = 500,
  154. API_APPLICATION_GETSCALEY = 510,
  155. };
  156. };
  157. // ----------------------------------------------------------------------------
  158. inline const wchar_t *api_application::main_getAppName()
  159. {
  160. const wchar_t *__retval = _call(API_APPLICATION_MAIN_GETAPPNAME, (const wchar_t *)0);
  161. return __retval;
  162. }
  163. inline const wchar_t *api_application::main_getVersionString()
  164. {
  165. const wchar_t *__retval = _call(API_APPLICATION_MAIN_GETVERSIONSTRING, (const wchar_t *)0);
  166. return __retval;
  167. }
  168. inline const wchar_t *api_application::main_getVersionNumString()
  169. {
  170. return _call(API_APPLICATION_MAIN_GETVERSIONSTRING2, (const wchar_t *)0);
  171. }
  172. inline unsigned int api_application::main_getBuildNumber()
  173. {
  174. return _call(API_APPLICATION_MAIN_GETBUILDNUMBER, 0);
  175. }
  176. inline GUID api_application::main_getGUID()
  177. {
  178. GUID __retval = _call(API_APPLICATION_MAIN_GETGUID, INVALID_GUID);
  179. return __retval;
  180. }
  181. #ifdef _WIN32
  182. inline HANDLE api_application::main_getMainThreadHandle()
  183. {
  184. HANDLE __retval = _call(API_APPLICATION_MAIN_GETMAINTHREADHANDLE, (HANDLE)NULL);
  185. return __retval;
  186. }
  187. inline HINSTANCE api_application::main_gethInstance()
  188. {
  189. HINSTANCE __retval = _call(API_APPLICATION_MAIN_GETHINSTANCE, (HINSTANCE)NULL);
  190. return __retval;
  191. }
  192. #endif
  193. inline const wchar_t *api_application::main_getCommandLine()
  194. {
  195. const wchar_t *__retval = _call(API_APPLICATION_MAIN_GETCOMMANDLINE, (const wchar_t *)0);
  196. return __retval;
  197. }
  198. inline void api_application::main_shutdown(int deferred)
  199. {
  200. _voidcall(API_APPLICATION_MAIN_SHUTDOWN, deferred);
  201. }
  202. inline void api_application::main_cancelShutdown()
  203. {
  204. _voidcall(API_APPLICATION_MAIN_CANCELSHUTDOWN);
  205. }
  206. inline int api_application::main_isShuttingDown()
  207. {
  208. int __retval = _call(API_APPLICATION_MAIN_ISSHUTTINGDOWN, (int)0);
  209. return __retval;
  210. }
  211. inline const wchar_t *api_application::path_getAppPath()
  212. {
  213. const wchar_t *__retval = _call(API_APPLICATION_PATH_GETAPPPATH, (const wchar_t *)0);
  214. return __retval;
  215. }
  216. inline const wchar_t *api_application::path_getUserSettingsPath()
  217. {
  218. return _call(API_APPLICATION_PATH_GETUSERSETTINGSPATH, (const wchar_t *)0);
  219. }
  220. inline const wchar_t *api_application::path_getSkinSettingsPath()
  221. {
  222. return _call(API_APPLICATION_PATH_GETSKINSETTINGSPATH, (const wchar_t *)0);
  223. }
  224. inline int api_application::app_getInitCount()
  225. {
  226. int __retval = _call(API_APPLICATION_APP_GETINITCOUNT, 0);
  227. return __retval;
  228. }
  229. inline intptr_t api_application::app_messageLoopStep()
  230. {
  231. return _call(API_APPLICATION_APP_MESSAGELOOPSTEP, (intptr_t)1);
  232. }
  233. #ifdef _WIN32
  234. inline void api_application::app_addMessageProcessor(ifc_messageprocessor *processor)
  235. {
  236. _voidcall(API_APPLICATION_APP_ADDMESSAGEPROCESSOR, processor);
  237. }
  238. inline void api_application::app_removeMessageProcessor(ifc_messageprocessor *processor)
  239. {
  240. _voidcall(API_APPLICATION_APP_REMOVEMESSAGEPROCESSOR, processor);
  241. }
  242. inline void api_application::app_addAccelerators(HWND hwnd, HACCEL *phAccel, INT cAccel, UINT translateMode)
  243. {
  244. _voidcall(API_APPLICATION_APP_ADDACCELERATORS, hwnd, phAccel, cAccel, translateMode);
  245. }
  246. inline void api_application::app_removeAccelerators(HWND hwnd)
  247. {
  248. _voidcall(API_APPLICATION_APP_REMOVEACCELERATORS, hwnd);
  249. }
  250. inline bool api_application::app_translateAccelerators(MSG *msg)
  251. {
  252. return _call(API_APPLICATION_APP_TRANSLATEACCELERATORS, (bool)false, msg);
  253. }
  254. inline int api_application::app_getAccelerators(HWND hwnd, HACCEL *phAccel, INT cchAccelMax, BOOL bGlobal)
  255. {
  256. return _call(API_APPLICATION_APP_GETACCELERATORS, (int)0, hwnd, phAccel, cchAccelMax, bGlobal);
  257. }
  258. inline void api_application::app_registerGlobalWindow(HWND hwnd)
  259. {
  260. _voidcall(API_APPLICATION_APP_REGISTERGLOBALWINDOW, hwnd);
  261. }
  262. inline void api_application::app_unregisterGlobalWindow(HWND hwnd)
  263. {
  264. _voidcall(API_APPLICATION_APP_UNREGISTERGLOBALWINDOW, hwnd);
  265. }
  266. inline bool api_application::DirectMouseWheel_RegisterSkipClass(ATOM klass)
  267. {
  268. return _call(API_APPLICATION_DIRECTMOUSEWHEEL_REGISTERSKIPCLASS, (bool)false, klass);
  269. }
  270. inline bool api_application::DirectMouseWheel_UnregisterSkipClass(ATOM klass)
  271. {
  272. return _call(API_APPLICATION_DIRECTMOUSEWHEEL_UNREGISTERSKIPCLASS, (bool)false, klass);
  273. }
  274. inline bool api_application::DirectMouseWheel_EnableConvertToMouseWheel(HWND hwnd, BOOL enable)
  275. {
  276. return _call(API_APPLICATION_DIRECTMOUSEWHEEL_ENABLECONVERTTOMOUSEWHEEL, (bool)false, hwnd, enable);
  277. }
  278. inline BOOL api_application::DirectMouseWheel_ProcessDialogMessage(HWND hwnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam, const int controls[], int controlslen)
  279. {
  280. return _call(API_APPLICATION_DIRECTMOUSEWHEEL_PROCESSDIALOGMESSAGE, (BOOL)FALSE, hwnd, uMsg, wParam, lParam, controls, controlslen);
  281. }
  282. inline void api_application::ActiveDialog_Register(HWND hwnd)
  283. {
  284. _voidcall(API_APPLICATION_ACTIVEDIALOG_REGISTER, hwnd);
  285. }
  286. inline void api_application::ActiveDialog_Unregister(HWND hwnd)
  287. {
  288. _voidcall(API_APPLICATION_ACTIVEDIALOG_UNREGISTER, hwnd);
  289. }
  290. inline HWND api_application::ActiveDialog_Get()
  291. {
  292. return _call(API_APPLICATION_ACTIVEDIALOG_GET, (HWND)NULL);
  293. }
  294. inline const wchar_t *api_application::getATFString()
  295. {
  296. return _call(API_APPLICATION_GETATFSTRING, (wchar_t *)0);
  297. }
  298. inline int api_application::getScaleX(int x)
  299. {
  300. return _call(API_APPLICATION_GETSCALEX, (int)0, x);
  301. }
  302. inline int api_application::getScaleY(int y)
  303. {
  304. return _call(API_APPLICATION_GETSCALEY, (int)0, y);
  305. }
  306. #endif
  307. inline const wchar_t *api_application::path_getWorkingPath()
  308. {
  309. return _call(API_APPLICATION_PATH_GETWORKINGPATH, (wchar_t *)0);
  310. }
  311. inline void api_application::path_setWorkingPath(const wchar_t *newPath)
  312. {
  313. _voidcall(API_APPLICATION_PATH_SETWORKINGPATH, newPath);
  314. }
  315. inline int api_application::GetMachineID(GUID *id)
  316. {
  317. return _call(API_APPLICATION_GETMACHINEID, (int)API_APPLICATION_FAILURE, id);
  318. }
  319. inline int api_application::GetUserID(GUID *id)
  320. {
  321. return _call(API_APPLICATION_GETUSERID, (int)API_APPLICATION_FAILURE, id);
  322. }
  323. inline int api_application::GetSessionID(GUID *id)
  324. {
  325. return _call(API_APPLICATION_GETSESSIONID, (int)API_APPLICATION_FAILURE, id);
  326. }
  327. inline size_t api_application::AllocateThreadStorage()
  328. {
  329. return _call(API_APPLICATION_ALLOCATETHREADSTORAGE, (size_t)-1);
  330. }
  331. inline void *api_application::GetThreadStorage(size_t index)
  332. {
  333. return _call(API_APPLICATION_GETTHREADSTORAGE, (void *)0, index);
  334. }
  335. inline void api_application::SetThreadStorage(size_t index, void *value)
  336. {
  337. _voidcall(API_APPLICATION_SETTHREADSTORAGE, index, value);
  338. }
  339. // ----------------------------------------------------------------------------
  340. // {23B96771-09D7-46d3-9AE2-20DCEA6C86EA}
  341. static const GUID applicationApiServiceGuid =
  342. {
  343. 0x23b96771, 0x9d7, 0x46d3, { 0x9a, 0xe2, 0x20, 0xdc, 0xea, 0x6c, 0x86, 0xea }
  344. };
  345. extern api_application *applicationApi;
  346. #endif // __API_APPLICATION_H