コード例 #1
0
//*****************************************************************************
//
//  Deletes the resources held by the object, optionally confirming the 
//  credential with the operating system.
//
//*****************************************************************************
Kerr::PromptForCredential::~PromptForCredential()
{
    if (!m_disposed)
    {
        delete m_password;
        m_password = nullptr;

        delete m_banner;
        m_banner = nullptr;

        if (SaveChecked && ExpectConfirmation && !m_confirmed)
        {
            pin_ptr<const wchar_t> pinnedTargetName = PtrToStringChars(m_targetName);

            ::CredUIConfirmCredentials(pinnedTargetName,
                                       FALSE);
        }

        m_disposed = true;
    }

    Debug::Assert(nullptr == m_password);
}
コード例 #2
0
ファイル: Evol3D.Net.cpp プロジェクト: YOlodfssdf/evolution3d
				PostMessage(m_hParentWnd , msg.sSysMsg.nMsg , msg.sSysMsg.wParam , msg.sSysMsg.lParam);
			return true;
		}

	Boolean xEvol3DEnv::ResizeRenderWindow(int w , int h)
	{
		x2DRect _rect;
		m_pWindow->getWindRect(_rect);
		if(_rect.w == w && _rect.h == h)
			return true;
        m_pWindow->setWindowSize(w , h);
		return true;
	}
	Boolean xEvol3DEnv::Init(String^ _xmlCfg , int hWnd , int hParentWnd , String^ _plugDir)
	{
		pin_ptr<const wchar_t> xmlCfg   = PtrToStringChars(_xmlCfg);
		pin_ptr<const wchar_t> plugDir  = PtrToStringChars(_plugDir);

		m_cfgDocument = new xXmlDocument;
		wchar_t appName[512] = {0};
		::GetModuleFileName(NULL, appName , 512);
		xOperationSys::singleton()->init(appName);
		XEVOL_LOG_SET_LEVEL( eXR_LOG_LEVEL(eXL_DEBUG_TIPS - 1) );
		m_cfgDocument->load( _XEVOL_ABSPATH_(xmlCfg) );
		xPluginMgr::singleton()->loadPluginDir( _XEVOL_ABSPATH_( plugDir) );
		xR_CreatePlatform(L"Win32");
		m_platform = IPlatform::singleton();
		XEVOL_LOG_REDIR( _XEVOL_ABSPATH_(L".\\XEvolLogger.txt") );

		WIN_CREATE_STRUCT cs;
		wcsncpy(cs.m_Caption , L"ÎÒµÄD3D10ÑÝʾ³ÌÐò",64);
コード例 #3
0
ファイル: Utils.cpp プロジェクト: apn99/CefSharp
namespace CefSharp
{
String^ toClr(const cef_string_t& cefStr)
{
    return gcnew String(cefStr.str);
}

String^ toClr(const CefString& cefStr)
{
    return gcnew String(cefStr.c_str());
}

CefString toNative(String^ str)
{
    pin_ptr<const wchar_t> pStr = PtrToStringChars(str);
    CefString cefStr(pStr);
    return cefStr;
}

void assignFromString(cef_string_t& cefStrT, String^ str)
{
    cef_string_clear(&cefStrT);
    if(str != nullptr)
    {
        pin_ptr<const wchar_t> pStr = PtrToStringChars(str);
        cef_string_copy(pStr, str->Length, &cefStrT);
    }
}

CefRefPtr<CefV8Value> convertToCef(Object^ obj, Type^ type)
コード例 #4
0
#include "StdAfx.h"
#include "utilities.h"
#include <pugixml.hpp>


utilities::utilities(void)
{
}

char* utilities::formToChar(String ^data)
{
	pin_ptr<const wchar_t> wch = PtrToStringChars(data);
	size_t convertedChars = 0;
	size_t  sizeInBytes = ((data->Length + 1) * 2);
	errno_t err = 0;
	char *ch = (char *)malloc(sizeInBytes);
	err = wcstombs_s(&convertedChars, 
					ch, sizeInBytes,
					wch, sizeInBytes);
	if (err != 0)
		printf_s("wcstombs_s  failed!\n");

	return ch;
}

void utilities::initXML()
{
	pugi::xml_document doc;
	if (!doc.load_file("FSCM.xml")){
		pugi::xml_node main = doc.append_child("FSCM");
コード例 #5
0
ファイル: mstartup.cpp プロジェクト: jetlive/skiaming
    void Create()
    {
        if ( ActivationCtxHandle != INVALID_HANDLE_VALUE )
        {
            return ;
        }

        HMODULE hKernel = GetModuleHandleW( L"KERNEL32" );
        if ( GetProcAddress( hKernel, "CreateActCtxW" ) == NULL )
        {
            // Pre XP OS
            return;
        }

        bool ManifestInFile = false;

        System::Reflection::Assembly^ CurrentAssembly = System::Reflection::Assembly::GetCallingAssembly();
        String^ AssemblyPath = CurrentAssembly->Location;
        try
        {
                if ( AssemblyPath == "" )
                {
                    String^ TempPath = System::IO::Path::GetTempFileName();
                    System::IO::StreamWriter^ sw = System::IO::File::CreateText(TempPath);
                    sw->Write (
                        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
                        "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n"
                        "   <dependency>\n"
                        "       <dependentAssembly>\n"
                        "           <assemblyIdentity\n"
                        "               type='win32'\n"
#ifdef _DEBUG
                        "               name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".DebugCRT'\n"
#else  /* _DEBUG */
                        "               name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT'\n"
#endif  /* _DEBUG */
                        "               version='" _CRT_ASSEMBLY_VERSION "'\n"
#ifdef _M_IX86
                        "               processorArchitecture='x86'\n"
#endif  /* _M_IX86 */
#ifdef _M_AMD64
                        "               processorArchitecture='amd64'\n"
#endif  /* _M_AMD64 */
#ifdef _M_IA64
                        "               processorArchitecture='ia64'\n"
#endif  /* _M_IA64 */
                        "               publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'/>\n"
                        "       </dependentAssembly>\n"
                        "   </dependency>\n"
                        "</assembly>\n"
                    );
                    sw->Close();
                    ManifestInFile = true;
                    AssemblyPath = TempPath;
                }

                cli::pin_ptr<const System::Char> pAssemblyPath = PtrToStringChars(AssemblyPath);

                ACTCTXW actctx;
                // Don't call memset. memset results in a call to msvcr*.dll which can be loaded from WinSXS
                // only after the activation context is activated.
                actctx.wProcessorArchitecture = 0;
                actctx.wLangId = 0;
                actctx.lpAssemblyDirectory = NULL;
                actctx.lpApplicationName = NULL;
                actctx.hModule = NULL;

                actctx.cbSize = sizeof( actctx );
                actctx.lpSource = pAssemblyPath;
                if (ManifestInFile)
                {
                    actctx.lpResourceName = 0;
                    actctx.dwFlags = 0;
                }
                else
                {
                    actctx.lpResourceName = MAKEINTRESOURCEW( 2 );
                    actctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
                }

                ActivationCtxHandle = CreateActCtxW( &actctx );
                if ( ActivationCtxHandle == INVALID_HANDLE_VALUE )
                {
                    if (!ManifestInFile)
                    {
                        actctx.lpResourceName = MAKEINTRESOURCEW( 1 );
                        ActivationCtxHandle = CreateActCtxW( &actctx );
                    }
                    if ( ActivationCtxHandle == INVALID_HANDLE_VALUE )
                    {
                    }
                }
            }
            finally
            {
                if (ManifestInFile)
                {
                    System::IO::File::Delete(AssemblyPath);
                }
            }
    }
コード例 #6
0
ファイル: pch.hpp プロジェクト: 2asoft/xray-16
#include <malloc.h>
#pragma managed

#include <stdlib.h>
#include <vcclr.h>

#pragma warning(disable:4127)
#pragma warning(disable:4100)

// do not forget to call
// 'cs_free'
// on the block of memory being returned
inline LPSTR to_string			(System::String ^string)
{
   // Pin memory so GC can't move it while native function is called
	pin_ptr<const wchar_t>		wch = PtrToStringChars(string);

	size_t						convertedChars = 0;
	size_t						sizeInBytes = ((string->Length + 1) * 2);
	errno_t						err = 0;
	LPSTR						result = (LPSTR)malloc(sizeInBytes);

	err							=
		wcstombs_s	(
			&convertedChars, 
			result,
			sizeInBytes,
			wch,
			sizeInBytes
		);
コード例 #7
0
ファイル: OVLReader.cpp プロジェクト: Joeywp/SVDTester
#include "StdAfx.h"
#include "OVLReader.h"

bool ToString( String^ source, string &target )
{
	pin_ptr<const wchar_t> wch = PtrToStringChars( source );
	int len = (( source->Length+1) * 2);
	char *ch = new char[ len ];
	bool result = wcstombs( ch, wch, len ) != -1;
	target = ch;
	delete ch;
	return result;
}

string OVLReader::LowerCase(string convert)
{
	string retstr;
	String^ tmpconv = gcnew String(convert.c_str());
	tmpconv = tmpconv->ToLower();
	ToString(tmpconv, retstr);
	return retstr;
}

string OVLReader::PointerdataAtOffset(ulong offset)
{
	ulong i = 0, j = 0;
	for(j = 0; j < 2; j++)
	{
		for(i = 0; i < OVLD[j].symbolstring.size(); i++)
		{
			if(OVLD[j].symbolstring[i].internal_offset == offset)
コード例 #8
0
ファイル: mivtmanaged.cpp プロジェクト: alvin-me/MIVT
// This is the main DLL file.

#include "stdafx.h"

#include "mivtmanaged.h"
#include "application.h"

namespace mivtmanaged {

  std::string FromManaged(String^ str)
  {
    std::string result;
    size_t converted = 0;
    char charBuffer[8192] = { 0 };
    pin_ptr<const wchar_t> pinned_string = PtrToStringChars(str);
    wcstombs_s(&converted, charBuffer, sizeof(charBuffer), pinned_string, str->Length);
    result.assign(charBuffer);

    return result;
  }

  String^ ToManaged(const std::string& str)
  {
    return System::Runtime::InteropServices::Marshal::PtrToStringAnsi(
      static_cast<IntPtr>(const_cast<char*>(str.c_str())));
  }

  Application::Application() {
    local_ = new mivt::Application(true);
  }
コード例 #9
0
ファイル: ManagedConnector.cpp プロジェクト: 29988122/KeyKey
    IMEServer::SharedIMEServer()->sendCharToClient((char)c);
}

void ManagedConnector::gotoPrevPage()
{
	sendChar(OVKeyCode::PageUp);
}

void ManagedConnector::gotoNextPage()
{
	sendChar(OVKeyCode::PageDown);
}

void ManagedConnector::sendString(String ^text)
{
    pin_ptr<const wchar_t> wchptr = PtrToStringChars(text);
	IMEServer::SharedIMEServer()->sendStringToClient(OVUTF8::FromUTF16(wchptr));
}

String^ ManagedConnector::primaryInputMethod()
{
    wstring im = OVUTF16::FromUTF8(IMEServer::SharedLoader()->primaryInputMethod());        
    return gcnew String(im.c_str());
}

void ManagedConnector::setPrimaryInputMethod(String ^moduleIdentifier, bool sendFakeKeyToCleanUpState)
{
    pin_ptr<const wchar_t> wchptr = PtrToStringChars(moduleIdentifier);
    wstring wstr = wchptr;        

    wstring im = OVUTF16::FromUTF8(IMEServer::SharedLoader()->primaryInputMethod());        
コード例 #10
0
ファイル: Irrlicht.NET.cpp プロジェクト: jivibounty/irrlicht
void IrrlichtDevice::set_WindowCaption(System::String* text)
{
	const wchar_t __pin* pinchars = PtrToStringChars(text); 
	Device->setWindowCaption(pinchars);
}
コード例 #11
0
// ManageCppDll.cpp
#include "stdafx.h"
#include "CoreManageDll.h"
#include <vcclr.h>
namespace CoreManageDll
{
	// 在构造函数中创建类CPerson的对象并在析构函数中将该对象销毁
	// 所有的成员函数实现都是通过指针m_pImp调用类CPerson的相应成员函数实现
	Core::Core()
	{
		m_pImp = new CCore();
	}
	Core::Core(String ^ strName, Char cSex, int iAge)
	{
		// 将string转换成C++能识别的指针
		pin_ptr<const wchar_t> wcName = PtrToStringChars(strName);
		m_pImp = new CCore(wcName, cSex, iAge);
	}
	Core::~Core()
	{
		// 在析构函数中删除CPerson对象
		delete m_pImp;
	}
	void Core::Name::set(String ^ strName)
	{
		pin_ptr<const wchar_t> wcName = PtrToStringChars(strName);
		m_pImp->SetName(wcName);
	}
	String ^ Core::Name::get()
	{
		return gcnew String(m_pImp->GetName());