Sha256: 996426827fad568c11c38a5873adbf1995414133d66ea380e847fae0a61c465f
Contents?: true
Size: 1.4 KB
Versions: 6
Compression:
Stored size: 1.4 KB
Contents
#include "StdAfx.h" #include "StringHelper.h" void StringHelper::CopyToUnmanagedString(String^ source, char* destination, const int destinationSize) { auto unmanagedString = Marshal::StringToHGlobalAnsi(source); strncpy(destination, (const char*)(void*)unmanagedString, destinationSize); 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]; } } 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
6 entries across 6 versions & 1 rubygems