天下

记录修行的印记

C++ CLI 可变参数

namespace TK 
{
    public enum class LogLevel { Kernel, Fatal, Error, Warning, Infomation, Debug};
    public ref class LogHelper
    {
    public:
        static bool Open(String^ filename);
        static void Close();
        static bool Write(LogLevel level,String^ format, array<Object^>^ args);
        static bool WriteLine(LogLevel level,String^ format, array<Object^>^ args);
        static void SetLevel(LogLevel level);
    };
}


static void MarshalString(String^ net, CString& os) {
    LPCTSTR chars = (LPCTSTR)(Marshal::StringToHGlobalUni(net)).ToPointer();
    os = chars;
    Marshal::FreeHGlobal(IntPtr((void*)chars));
}
#pragma unmanaged
static CStringA CStrW2CStrA(const CStringW &cstrSrcW)
{
    int len = WideCharToMultiByte(CP_UTF8, 0, LPCWSTR(cstrSrcW), -1, NULL, 0, NULL, NULL);
    char *str = new char[len];
    memset(str, 0, len);
    WideCharToMultiByte(CP_UTF8, 0, LPCWSTR(cstrSrcW), -1, str, len, NULL, NULL);
    CStringA cstrDestA = str;
    delete[] str;

    return cstrDestA;
}
#pragma managed

posted on 2016-09-01 14:48 天下 阅读(493) 评论(0)  编辑 收藏 引用 所属分类: C/C++C#


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2016年9月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

导航

统计

常用链接

留言簿(4)

随笔分类(378)

随笔档案(329)

链接

最新随笔

搜索

最新评论