ACE clipboard extension to bypass clipboard limit of arma. Close #991

This commit is contained in:
jaynus 2015-05-02 13:13:24 -07:00
parent 7678919e8d
commit 433bb21ccc
4 changed files with 70 additions and 0 deletions

BIN
ace_clipboard.dll Normal file

Binary file not shown.

View File

@ -56,6 +56,7 @@ set(GLOBAL_SOURCES ${GLOBAL_RC})
# Add extensions to build here
add_subdirectory(fcs)
add_subdirectory(break_line)
add_subdirectory(clipboard)
add_subdirectory(advanced_ballistics)
message("Build Type: ${CMAKE_BUILD_TYPE}")

View File

@ -0,0 +1,12 @@
set(ACE_EXTENSION_NAME "ace_clipboard")
file(GLOB SOURCES *.h *.hpp *.c *.cpp)
add_library( ${ACE_EXTENSION_NAME} SHARED ${SOURCES} ${GLOBAL_SOURCES})
target_link_libraries(${ACE_EXTENSION_NAME} ace_common)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "")
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()

View File

@ -0,0 +1,57 @@
/*
* ace_clipboard.cpp
*
* Takes a string and copies it to the clipboard; bypasses arma 8k clippy limit.
*
* Takes:
* Localized string as string
*
* Returns:
* None
*/
#include "ace_common.h"
#include <vector>
#include <string>
extern "C" {
__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
};
void __stdcall RVExtension(char *output, int outputSize, const char *function) {
std::string input(function);
std::string result;
if (input.length() < 1)
return;
#ifdef _WIN32
HGLOBAL glob = GlobalAlloc(GMEM_FIXED, input.length()+1);
memcpy(glob, input.c_str(), input.length());
((char *)glob)[input.length() + 1] = 0x00;
if (!OpenClipboard(NULL)) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
} else {
if (!EmptyClipboard()) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
} else {
if (!SetClipboardData(CF_TEXT, glob)) {
result = "SetClipboardData() failed, GetLastError=" + GetLastError();
} else {
if (!CloseClipboard()) {
result = "CloseClipboard() failed, GetLastError=" + GetLastError();
}
}
}
}
end:
memcpy(output, result.c_str(), result.length()+1);
#endif
}