Sha256: eb62bfc170e3cf477ee2129e96c9be7faf78e550681a12eae5dac6b3c52a9c89
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
#include "StdAfx.h" #include "StringHelper.h" void StringHelper::CopyToUnmanagedString(String^ source, char* destination, const int destinationSize) { auto unmanagedString = Marshal::StringToHGlobalAnsi(source); strncpy_s(destination, destinationSize, (const char*)(void*)unmanagedString, _TRUNCATE); Marshal::FreeHGlobal(unmanagedString); } char* StringHelper::UnmanagedStringFrom(String^ source) { const int numberOfBytes = source->Length + 1; auto unmanagedString = new char[numberOfBytes]; CopyToUnmanagedString(source, unmanagedString, numberOfBytes); return unmanagedString; } void StringHelper::FreeUp(const char* unmanagedStrings[], const int numberOfStrings) { for(auto whichString = 0; whichString < numberOfStrings; ++whichString) { delete[] unmanagedStrings[whichString]; } } int StringHelper::Copy(array<String^>^ strings, const char* unmanagedStrings[]) { if( NULL != unmanagedStrings ) { auto whichItem = 0; for each(String^ theString in strings) { unmanagedStrings[whichItem++] = UnmanagedStringFrom(theString); } } return strings->Length; } void StringHelper::CopyNames(AutomationElementCollection^ automationElements, const char* unmanagedStrings[]) { auto whichItem = 0; for each(AutomationElement^ automationElement in automationElements) { unmanagedStrings[whichItem++] = UnmanagedStringFrom(automationElement->Current.Name); } } void StringHelper::CopyClassNames(AutomationElementCollection^ automationElements, const char* unmanagedStrings[]) { auto whichItem = 0; for each(AutomationElement^ automationElement in automationElements) { unmanagedStrings[whichItem++] = UnmanagedStringFrom(automationElement->Current.ClassName); } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rautomation-0.12.0 | ext/UiaDll/UiaDll/StringHelper.cpp |
rautomation-0.11.0 | ext/UiaDll/UiaDll/StringHelper.cpp |