OSDN Git Service

Fix bugs of uninitialized variables.
[ffftp/ffftp.git] / clipboard.c
1 /*=============================================================================\r
2 *\r
3 *                                                               クリップボード関係\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 #define  STRICT\r
31 // IPv6対応\r
32 #include <winsock2.h>\r
33 #include <windows.h>\r
34 #include <stdio.h>\r
35 #include <stdlib.h>\r
36 #include <string.h>\r
37 #include <windowsx.h>\r
38 \r
39 #include "common.h"\r
40 #include "resource.h"\r
41 \r
42 \r
43 \r
44 /*----- 文字列をクリップボードにコピー ----------------------------------------\r
45 *\r
46 *       Parameter\r
47 *               char *Str : 文字列\r
48 *\r
49 *       Return Value\r
50 *               なし\r
51 *----------------------------------------------------------------------------*/\r
52 \r
53 int CopyStrToClipBoard(char *Str)\r
54 {\r
55         int Sts;\r
56         void *gBuf;\r
57         HGLOBAL hGlobal;\r
58 \r
59         Sts = FFFTP_FAIL;\r
60         if(OpenClipboard(GetMainHwnd()))\r
61         {\r
62                 if(EmptyClipboard())\r
63                 {\r
64                         if((hGlobal = GlobalAlloc(GHND, strlen(Str)+1)) != NULL)\r
65                         {\r
66                                 if((gBuf = GlobalLock(hGlobal)) != NULL)\r
67                                 {\r
68                                         strcpy(gBuf, Str);\r
69 \r
70                                         GlobalUnlock(hGlobal);\r
71                                         SetClipboardData(CF_TEXT, hGlobal);\r
72                                         Sts = FFFTP_SUCCESS;\r
73                                 }\r
74                         }\r
75                 }\r
76                 CloseClipboard();\r
77         }\r
78         return(Sts);\r
79 }\r
80 \r
81 \r