]> cygwin.com Git - cygwin-apps/setup.git/blame - cistring.cc
2001-12-22 Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
[cygwin-apps/setup.git] / cistring.cc
CommitLineData
ab57ceaa
RC
1/*\r
2 * Copyright (c) 2001, Gary R. Van Sickle.\r
3 *\r
4 * This program is free software; you can redistribute it and/or modify\r
5 * it under the terms of the GNU General Public License as published by\r
6 * the Free Software Foundation; either version 2 of the License, or\r
7 * (at your option) any later version.\r
8 *\r
9 * A copy of the GNU General Public License can be found at\r
10 * http://www.gnu.org/\r
11 *\r
12 * Written by Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>\r
13 *\r
14 */\r
15\r
16// Yep, another string class\r
17\r
18#include "cistring.h"\r
19#include <stdlib.h>\r
20\r
21DWORD\r
22cistring::Format (UINT i, ...)\r
23{\r
24 TCHAR FormatStringBuffer[256];\r
25 TCHAR *Buff;\r
26 va_list arglist;\r
27 DWORD numchars;\r
28\r
29 // Get the string from the stringtable (FormatMessage() can only work with\r
30 // literal strings or *message*table entries, which are different for some\r
31 // inexplicable reason).\r
32 LoadString (GetModuleHandle (NULL), i, FormatStringBuffer, 256);\r
33\r
34 va_start (arglist, i);\r
35 numchars =::\r
36 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |\r
37 FORMAT_MESSAGE_FROM_STRING, FormatStringBuffer, i, 0,\r
38 (LPTSTR) & Buff, 0, &arglist);\r
39 va_end (arglist);\r
40\r
41 if (numchars == 0)\r
42 {\r
43 // Something went wrong.\r
44 return 0;\r
45 }\r
46\r
47 buffer = new TCHAR[(numchars + 1) * sizeof (TCHAR)];\r
48 memcpy (buffer, Buff, (numchars + 1) * sizeof (TCHAR));\r
49 LocalFree (Buff);\r
50\r
51 return numchars;\r
52}\r
This page took 0.027343 seconds and 5 git commands to generate.