OSDN Git Service

Move *.c and *.h files to src
[ffftp/ffftp.git] / src / clipboard.c
diff --git a/src/clipboard.c b/src/clipboard.c
new file mode 100644 (file)
index 0000000..658f178
--- /dev/null
@@ -0,0 +1,81 @@
+/*=============================================================================\r
+*\r
+*                                                              クリップボード関係\r
+*\r
+===============================================================================\r
+/ Copyright (C) 1997-2007 Sota. All rights reserved.\r
+/\r
+/ Redistribution and use in source and binary forms, with or without \r
+/ modification, are permitted provided that the following conditions \r
+/ are met:\r
+/\r
+/  1. Redistributions of source code must retain the above copyright \r
+/     notice, this list of conditions and the following disclaimer.\r
+/  2. Redistributions in binary form must reproduce the above copyright \r
+/     notice, this list of conditions and the following disclaimer in the \r
+/     documentation and/or other materials provided with the distribution.\r
+/\r
+/ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
+/ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
+/ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
+/ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
+/ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
+/ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
+/ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
+/ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+/ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
+/ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+/============================================================================*/\r
+\r
+#define  STRICT\r
+// IPv6対応\r
+#include <winsock2.h>\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <windowsx.h>\r
+\r
+#include "common.h"\r
+#include "resource.h"\r
+\r
+\r
+\r
+/*----- 文字列をクリップボードにコピー ----------------------------------------\r
+*\r
+*      Parameter\r
+*              char *Str : 文字列\r
+*\r
+*      Return Value\r
+*              なし\r
+*----------------------------------------------------------------------------*/\r
+\r
+int CopyStrToClipBoard(char *Str)\r
+{\r
+       int Sts;\r
+       void *gBuf;\r
+       HGLOBAL hGlobal;\r
+\r
+       Sts = FFFTP_FAIL;\r
+       if(OpenClipboard(GetMainHwnd()))\r
+       {\r
+               if(EmptyClipboard())\r
+               {\r
+                       if((hGlobal = GlobalAlloc(GHND, strlen(Str)+1)) != NULL)\r
+                       {\r
+                               if((gBuf = GlobalLock(hGlobal)) != NULL)\r
+                               {\r
+                                       strcpy(gBuf, Str);\r
+\r
+                                       GlobalUnlock(hGlobal);\r
+                                       SetClipboardData(CF_TEXT, hGlobal);\r
+                                       Sts = FFFTP_SUCCESS;\r
+                               }\r
+                       }\r
+               }\r
+               CloseClipboard();\r
+       }\r
+       return(Sts);\r
+}\r
+\r
+\r