rtoss - Blame information for rev 182

Subversion Repositories:
Rev:
Rev Author Line No. Line
181 roytam 1 /* ----------------------------------------------------------------------------
2  
3     gen_tbar
4     ========
5     Winamp plugin to display customizable data on window captions
6  
7     Copyright (c) 1999-2000 Jos van den Oever (http://www.vandenoever.info/)
8     Copyright (c) 2005 Martin Zuther (http://www.mzuther.de/)
9  
10     This program is free software; you can redistribute it and/or modify
11     it under the terms of the GNU General Public License as published by
12     the Free Software Foundation; either version 2 of the License, or
13     (at your option) any later version.
14  
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     GNU General Public License for more details.
19  
20     You should have received a copy of the GNU General Public License
21     along with this program; if not, write to the Free Software
22     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  
24 -------------------------------------------------------------------------------
25  
26     Notify CD Player
27     ================
28     Copyright (c) 1996-1997 Mats Ljungqvist (mlt@cyberdude.com)
29  
30     StdString
31     =========
32     Copyright (c) 2002 Joseph M. O'Leary.  This code is 100% free.  Use it
33     anywhere you want. Rewrite it, restructure it, whatever.  If you can write
34     software that makes money off of it, good for you.  I kinda like capitalism.
35     Please don't blame me if it causes your $30 billion dollar satellite explode
36     in orbit. If you redistribute it in any form, I'd appreciate it if you would
37     leave this notice here.
38  
39 ---------------------------------------------------------------------------- */
40  
41 // gen_tbar_2.cpp : Defines the entry point for the DLL application.
42 //
43  
44 #include "gen_tbar_2.h"
45  
46 gen_tbar* p_gen_tbar;
47  
48 BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
49 {
50         return TRUE;
51 }
52  
53 winampGeneralPurposePlugin plugin =
54 {
55         GPPHDR_VER,
56         "Titlebar Info",
57         init,
58         config,
59         quit,
60 };
61  
62 int init()
63 {
64         HINSTANCE hInstance = plugin.hDllInstance;
65         HWND hWndParent     = plugin.hwndParent;
66  
67         // Get version information from DLL
68         CStdString strHelpFile;
69         CStdString strVersion;
70  
71         GetModuleFileName(hInstance, strHelpFile.GetBuffer(MAX_PATH), MAX_PATH);
72         strHelpFile.ReleaseBuffer();
73  
74         strVersion = strHelpFile;
75         PathRemoveFileSpec(strHelpFile.GetBuffer(MAX_PATH));
76         strHelpFile.ReleaseBuffer();
182 roytam 77         strHelpFile += _T("\\gen_tbar.chm");
181 roytam 78  
79         DWORD dwArg;
80         DWORD dwInfoSize = GetFileVersionInfoSize(strVersion.GetBuffer(MAX_PATH), &dwArg);
81         strVersion.ReleaseBuffer();
82  
83         BYTE* lpBuffer = new BYTE[dwInfoSize];
84         GetFileVersionInfo(strVersion.GetBuffer(MAX_PATH), NULL, dwInfoSize, lpBuffer);
85         strVersion.ReleaseBuffer();
86  
87         UINT uInfoSize;
88         LPVOID lpValue;
89  
90         if (VerQueryValue(lpBuffer, TEXT("\\StringFileInfo\\040904b0\\FileVersion"), &lpValue, &uInfoSize))
182 roytam 91                 strVersion.Format(_T("Titlebar Info %s"), lpValue);
181 roytam 92         else
182 roytam 93                 strVersion = _T("Titlebar Info x.xx");
181 roytam 94  
95         delete[] lpBuffer;
96         lpBuffer = NULL;
97  
182 roytam 98 #ifndef _MBCS
99         strVersion += " [Unicode]";
100 #endif
101  
181 roytam 102         // Set plugin description
103         static char c[512];
104  
105         CStdString strFilename;
106         GetModuleFileName(hInstance, strFilename.GetBuffer(MAX_PATH), MAX_PATH);
107         strFilename.ReleaseBuffer();
182 roytam 108         std::string strVersionA, strFilenameA;
109         ssasn(strVersionA, strVersion.GetBuffer(MAX_PATH));
110         ssasn(strFilenameA, PathFindFileName(strFilename.GetBuffer(MAX_PATH)));
181 roytam 111  
182 roytam 112         wsprintfA((c), "%s (%s)", strVersionA.c_str(), strFilenameA.c_str()); // "%s" must be a pointer to char!
181 roytam 113         plugin.description = c;
114  
115         strFilename.ReleaseBuffer();
116         strVersion.ReleaseBuffer();
117  
118         p_gen_tbar = new gen_tbar(hInstance, hWndParent, strHelpFile, strVersion);
119  
120         return 0;
121 }
122  
123 void quit()
124 {
125         delete p_gen_tbar;
126         p_gen_tbar = NULL;
127 }
128  
129 void config()
130 {
131         p_gen_tbar->config();
132 }
133  
134 extern "C"
135 __declspec( dllexport ) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin()
136 {
137         return &plugin;
138 }