OSDN Git Service

Change to encode reply messages with Kanji code of filenames.
[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 #include <windows.h>\r
32 #include <stdio.h>\r
33 #include <stdlib.h>\r
34 #include <string.h>\r
35 #include <windowsx.h>\r
36 \r
37 #include "common.h"\r
38 #include "resource.h"\r
39 \r
40 \r
41 \r
42 /*----- 文字列をクリップボードにコピー ----------------------------------------\r
43 *\r
44 *       Parameter\r
45 *               char *Str : 文字列\r
46 *\r
47 *       Return Value\r
48 *               なし\r
49 *----------------------------------------------------------------------------*/\r
50 \r
51 int CopyStrToClipBoard(char *Str)\r
52 {\r
53         int Sts;\r
54         void *gBuf;\r
55         HGLOBAL hGlobal;\r
56 \r
57         Sts = FFFTP_FAIL;\r
58         if(OpenClipboard(GetMainHwnd()))\r
59         {\r
60                 if(EmptyClipboard())\r
61                 {\r
62                         if((hGlobal = GlobalAlloc(GHND, strlen(Str)+1)) != NULL)\r
63                         {\r
64                                 if((gBuf = GlobalLock(hGlobal)) != NULL)\r
65                                 {\r
66                                         strcpy(gBuf, Str);\r
67 \r
68                                         GlobalUnlock(hGlobal);\r
69                                         SetClipboardData(CF_TEXT, hGlobal);\r
70                                         Sts = FFFTP_SUCCESS;\r
71                                 }\r
72                         }\r
73                 }\r
74                 CloseClipboard();\r
75         }\r
76         return(Sts);\r
77 }\r
78 \r
79 \r