LiFan
9 天以前 63eebabbfee1bc84850b36967ecac5116a28b73f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
 
#include "xbase.hpp"
#include "kobject/kutil.hpp"
#include "wobject/xaserver.hpp"
#include "win32/win.hpp"
 
using kutil = Hxsoft::XFrame::IXFUtil;
extern "C" {
    void* WINAPI  GetProcAddressW(HMODULE hModule, const char* lpText);
}
class xutil
{
public:
    static HCURSOR  SetCursorWait()
    {
        return Hxsoft::XFrame::IXFUtil::SetCursorWait();
    }
 
    static int RestoreCursor(HCURSOR hCursor)
    {
       return Hxsoft::XFrame::IXFUtil::RestoreCursor(hCursor);
    }
    
    static const wchar_t* GetUrlData(const wchar_t* url)
    {
        return kutil::GetUrlData((LPWSTR)url);
    }
 
    static bool HasCacheData(const wchar_t* url)
    {
        return kutil::HasCacheData((LPWSTR)url);
    }
 
    static void CacheUrlData(const wchar_t* url,const wchar_t* data)
    {
        return kutil::CacheUrlData((LPWSTR)url,(LPWSTR)data);
    }
 
    static int SaveToFile(xstring pFile,xstring pData,xstring ext, xstring pFilter, const LPTSTR pFileName=NULL)
    {
        return kutil::SaveToFile((LPWSTR)pFile.c_str(), (LPWSTR)pData.c_str(), (LPWSTR)ext.c_str(), (LPWSTR)pFileName);
    }
    static LPWSTR MD5(const wchar_t* pStr)
    {
        return kutil::MD5((LPWSTR)pStr);
    }
    static bool SmallImage(LPCTSTR lpszPathName, LPCTSTR lpszNewPathName, int width, int height, int flag=0)
    {
        return kutil::SmallImage(lpszPathName,lpszNewPathName,width,height,flag);
    }
    static LPWSTR OpenDialog(HWND Owner,const wchar_t* str)
    {
        return kutil::OpenDialog(Owner,(LPWSTR)str);
    }
    static LPTSTR FormatDecimalString(LPTSTR  str, LPTSTR format, bool& bfree)
    {
        return Hxsoft::XUtil::FormatDecimalString(str, format, bfree);
    }
 
    static  xstring ToXmlTextAndStartSpace(xstring str)
    {
        wchar_t* xmlStr = Hxsoft::XUtil::ToXmlTextAndStartSpace(str.c_str());
        return xmlStr ? xmlStr : str;
    }
 
    static  xstring ToHtmlTextAndStartSpace(xstring str)
    {
        wchar_t* htmlStr = Hxsoft::XUtil::ToHtmlTextAndStartSpace(str.c_str());
        return htmlStr ? htmlStr : str;
    }
 
    static  xstring ToXmlText(xstring str)
    {
        wchar_t* xmlStr = Hxsoft::XUtil::ToXmlText(str.c_str());
        return xmlStr? xmlStr : str;
    }
    static  xstring ToHtmlText(xstring str)
    {
        wchar_t* htmlStr = Hxsoft::XUtil::ToHtmlText(str.c_str());
        return htmlStr? htmlStr : str;
    }
    static  xstring UnXMLText(xstring str)
    {
        wchar_t* xmlStr = Hxsoft::XUtil::UnXMLText(str.c_str());
        return xmlStr? xmlStr:str;
    }
 
public:
    static xstring GetModulePath()
    {
        wchar_t buf[255];
        ::GetModuleFileNameW(nullptr, buf, 255);
        PathRemoveFileSpec(buf);
        return xstring(buf);
    }
 
    static xstring GetModuleTmpPath()
    {
        xstring tmp = GetModulePath() + L"\\Temp";
        xaserver::CreateDirectory(tmp);
        return tmp;
    }
 
    static void* GetFuncPtr(const wchar_t* dll, const char* name)
    {
        void* fnAttachEvent = nullptr;
        HMODULE hModule = LoadLibraryW(dll);
        if (hModule)fnAttachEvent = ::GetProcAddressW(hModule, name);
        return fnAttachEvent;
    }
};