From 51faca7cff4ce6b848fcbd8f7fe881f6fc59b4f3 Mon Sep 17 00:00:00 2001 From: xj qian <qianxj15@sina.com> Date: 星期四, 27 六月 2024 16:06:03 +0800 Subject: [PATCH] add xfile --- jrj/xframe/adt/xarray.hpp | 128 ++++++++++++++++ jrj/xframe/wobject/xint.hpp | 2 jrj/xframe/wobject/xutil.hpp | 16 ++ jrj/xframe/wobject/xaserver.hpp | 8 jrj/xframe/win32/win.hpp | 20 + jrj/ext-jrj/ext-jrj.vcxproj | 7 jrj/project/business/quote.enquiry.cpp | 108 ++++-------- jrj/xframe/win32/xfile.hpp | 186 +++++++++++++++++++++++ jrj/xframe/kobject/kapp.hpp | 1 9 files changed, 394 insertions(+), 82 deletions(-) diff --git a/jrj/ext-jrj/ext-jrj.vcxproj b/jrj/ext-jrj/ext-jrj.vcxproj index 9535065..f598b94 100644 --- a/jrj/ext-jrj/ext-jrj.vcxproj +++ b/jrj/ext-jrj/ext-jrj.vcxproj @@ -169,6 +169,7 @@ <ClInclude Include="..\project\viewobject\saleorder.view.hpp" /> <ClInclude Include="..\project\viewobject\shoppingcart.view.hpp" /> <ClInclude Include="..\project\viewobject\supplier.view.hpp" /> + <ClInclude Include="..\xframe\adt\xarray.hpp" /> <ClInclude Include="..\xframe\kobject\kapp.hpp" /> <ClInclude Include="..\xframe\kobject\kbase.hpp" /> <ClInclude Include="..\xframe\kobject\kcachemgr.hpp" /> @@ -198,6 +199,8 @@ <ClInclude Include="..\xframe\vbusiness\vframe\maint.vframe.vbusiness.hpp" /> <ClInclude Include="..\xframe\vbusiness\vframe\responsewin.vframe.vbusiness.hpp" /> <ClInclude Include="..\xframe\vbusiness\vutil\publiccode.vutil.vbusiness.hpp" /> + <ClInclude Include="..\xframe\win32\win.hpp" /> + <ClInclude Include="..\xframe\win32\xfile.hpp" /> <ClInclude Include="..\xframe\wobject\xapp.hpp" /> <ClInclude Include="..\xframe\wobject\xaserver.hpp" /> <ClInclude Include="..\xframe\wobject\xaserverarg.hpp" /> @@ -252,7 +255,9 @@ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> - <ClCompile Include="..\project\business\quote.enquiry.cpp" /> + <ClCompile Include="..\project\business\quote.enquiry.cpp"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + </ClCompile> <ClCompile Include="..\project\business\Quote3.list3.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> </ClCompile> diff --git a/jrj/project/business/quote.enquiry.cpp b/jrj/project/business/quote.enquiry.cpp index a71d3a2..2e88c47 100644 --- a/jrj/project/business/quote.enquiry.cpp +++ b/jrj/project/business/quote.enquiry.cpp @@ -2188,7 +2188,7 @@ } //鐒︾偣婵�娲诲鐞嗗嚱鏁� - int OnSetFocus(ref TEvent evt, int param) + int OnSetFocus(TEvent* evt, LPARAM param) { //閲嶇疆宸ュ叿鏉� SetAgent(); @@ -2200,7 +2200,6 @@ xml x = ViewObject::RetrieveData(L"/sale/data/TO/template/param", L"TemplateID", id); xml sheet ; - sheet.setNativePointer(x.CreateInstance()); sheet.loadXML(x.selectSingleNode(L"data/*").xml); dw_cell.LoadTemplate(sheet); @@ -2257,30 +2256,6 @@ return 1; } - - static stdcall int GetModuleFileName(int hModule, xstring lpFileName, int nSize) native from "kernel32.dll" alias "GetModuleFileNameW"; - static stdcall int PathRemoveFileSpec(xstring lpFileName) native from "shlwapi.dll" alias "PathRemoveFileSpecW"; - - xstring GetModulePath() - { - xstring str = L""; - str = str.space(255); - GetModuleFileName(0, str, 250); - PathRemoveFileSpec(str); - return str; - } - - xstring GetModuleTmpPath() - { - xstring str = L""; - str = str.space(255); - GetModuleFileName(0, str, 250); - PathRemoveFileSpec(str); - xstring tmp = str + L"\\Temp"; - xaserver::CreateDirectory(tmp); - return tmp; - } - xstring UploadImage(xstring guid) { return UploadImage(guid, L""); @@ -2290,12 +2265,12 @@ { xstring name = guid + L".jpg"; xstring str = name.mid(0, 2); - str = str.upper(); + str = str.toUpper(); int ret = 1; if (filename != L"") - ret = xaserver::Upload(L"product" + str, name, filename, this.GetHWND(), L"", false); + ret = xaserver::Upload(L"product" + str, name, filename, GetHWND(), L"", false); else - ret = xaserver::Upload(L"product" + str, name, this.GetHWND(), L"", false); + ret = xaserver::Upload(L"product" + str, name.c_str(), GetHWND(), L"", false); if (ret == -1) return L""; if (ret == 0) { @@ -2315,7 +2290,7 @@ } xutil::SmallImage(appPath+L"\\"+name,appPath+L"\\"+L"x_"+name,120,120); - int ret_1 = xaserver::Upload(L"product"+str, L"x_"+name,appPath+L"\\x_"+name, this.GetHWND(),L"",false); + int ret_1 = xaserver::Upload(L"product"+str, L"x_"+name,appPath+L"\\x_"+name, GetHWND(),L"",false); //xaserver::DeleteFile(appPath+L"x_"+name); //xaserver::DeleteFile(appPath+name); if(ret_1 != 1) @@ -2331,12 +2306,12 @@ { xstring name = guid + L".jpg"; xstring str = name.mid(0, 2); - str = str.upper(); + str = str.toUpper(); int ret = 1; if (filename != L"") - ret = xaserver::Upload(L"product" + str, name, filename, this.GetHWND(), L"", false); + ret = xaserver::Upload(L"product" + str, name, filename, GetHWND(), L"", false); else - ret = xaserver::Upload(L"product" + str, name, this.GetHWND(), L"", false); + ret = xaserver::Upload(L"product" + str, name, GetHWND(), L"", false); if (ret == -1) return L""; if (ret == 0) { @@ -2354,7 +2329,7 @@ } xutil::SmallImage(appPath + L"\\" + name, appPath + L"\\" + L"x_" + name, 120, 120); - int ret_1 = xaserver::Upload(L"product" + str, L"x_" + name, appPath + L"\\x_" + name, this.GetHWND(), L"", false); + int ret_1 = xaserver::Upload(L"product" + str, L"x_" + name, appPath + L"\\x_" + name, GetHWND(), L"", false); //xaserver::DeleteFile(appPath+L"x_"+name); //xaserver::DeleteFile(appPath+name); if (ret_1 != 1) @@ -2617,24 +2592,23 @@ // "JPEG 鏂囦欢(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0鍏ㄩ儴鏂囦欢(*.*)\0*.*\0", // "jpg"); - char[] szFileName = new char[4096]; - char[] szPath = new char[4096]; + wchar_t szFileName[4096]; + wchar_t szPath[4096]; szFileName[0] = 0; szPath[0] = 0; if (initFileName != L"") { int len = initFileName.length(); - char[] tmp = initFileName; + const wchar_t* tmp = initFileName.c_str(); for (int i = 0; i < len + 1; i++) { - //szFileName[i] = tmp[i]; szPath[i] = tmp[i]; } } int nFilterIndex = 1; - ref OPENFILENAMEW ofn = new OPENFILENAMEW; + OPENFILENAMEW ofn; ofn.lStructSize = 88;//sizeof(ofn); ofn.hwndOwner = 0; @@ -3121,7 +3095,7 @@ return 1; } - int OnCellSelectChanged(ref TNotifyEvent evt, int p) + int OnCellSelectChanged(TEvent*, LPARAM p) { /*ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); xstring colname=hdr.colname; @@ -3132,7 +3106,7 @@ return 1; } - int OnItemChanged(ref TNotifyEvent evt, int p) + int OnItemChanged(TEvent*, LPARAM p) { ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); xstring colname = hdr.colname; @@ -3289,14 +3263,14 @@ xstring res = L"/sale/data/productlibrary3/pref/picture/imagelistskuno"; if (xurl::get(res, arg_pic.GetString(), xp) != 1) { - trace(xp.GetXml()); + trace(xp.xml()); return 1; } else { - //alert(xp.GetXml()); + //alert(xp.xml()); ClearImageTerm(row, L"customer-photo"); - //alert(xp.GetXml()); + //alert(xp.xml()); KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image"); int lenp = nlistp.length(); int ip = 0; @@ -3349,13 +3323,13 @@ xstring res = L"/sale/data/ProductLibrary3/pref/picture/imagelistItemNo"; if (xurl::get(res, arg_pic.GetString(), xp) != 1) { - trace(xp.GetXml()); + trace(xp.xml()); return 1; } else { ClearImageTerm(row, L"customer-photo"); - //alert(xp.GetXml()); + //alert(xp.xml()); KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image"); int lenp = nlistp.length(); int ip = 0; @@ -3735,7 +3709,7 @@ xstring GetExchangeRate(xstring pcur, xstring pdate) { - if (pcur.upper() == L"RMB") return L"1"; + if (pcur.toUpper() == L"RMB") return L"1"; xstring exchangeRate = L""; if (exchangeRate == L"") { xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); @@ -3792,9 +3766,9 @@ return 1; } - int OnRowChanged(ref TNotifyEvent evt, int p) + int OnRowChanged(TEvent* evt, LPARAM p) { - ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); + DWNMHDR& hdr = *(DWNMHDR * )evt->notify.pnmh; int row = hdr.row; return OnQuoteLineChanged(row); @@ -3803,7 +3777,7 @@ int OnQuoteLineChanged(int row) { ximageview im = GetControl(L"im1"); - im.ResetEx(); + im.Reset(); //xstring skuno = dw_goods.GetItemString(row,L"SKUNo"); //OnShowImage(skuno,row); //im.Redraw(); @@ -3827,9 +3801,7 @@ ximageview im = GetControl(L"im1"); xml xp ; - xp.setNativePointer(xml::CreateInstance()); xaserverarg arg_pic ; - arg_pic.setNativePointer(arg_pic.CreateInstance()); arg_pic.AddArg(L"SKUNo", skuno); xstring res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; @@ -3846,7 +3818,7 @@ bool hasIamge = false; if (xurl::get(res, arg_pic.GetString(), xp) != 1) { - trace(xp.GetXml()); + trace(xp.xml()); return 1; } else @@ -3869,18 +3841,18 @@ res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; if (xurl::get(res, arg_pic.GetString(), xp) != 1) { - trace(xp.GetXml()); + trace(xp.xml()); return 1; } else { - nlistp = xp.selectNodes(L"ImageList/image"); - lenp = nlistp.length(); - for (ip = 0; ip < lenp; ip++) + KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image"); + long lenp = nlistp.length(); + for (int ip = 0; ip < lenp; ip++) { - xitem = nlistp.item(ip); - picname = xitem.selectSingleNode(L"PicPath").text(); - goodno = xitem.selectSingleNode(L"GoodsNo").text(); + KXMLDOMNode xitem = nlistp.item(ip); + xstring picname = xitem.selectSingleNode(L"PicPath").text(); + xstring goodno = xitem.selectSingleNode(L"GoodsNo").text(); if (picname == L"/business/products/Thumbs//") picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg"; im.AddImages(picname, goodno); @@ -3920,7 +3892,7 @@ int OnUpdateProcessed() { int ret = ProcessSendMessage(L"/task/quote/update-processed", taskid, L"", L"", false); - win32::PostMessage(GetFrameWindow().GetHWND(), 0x401, L"xmRefreshTask", 0); + PostMessage(GetFrameWindow().GetHWND(), 0x401, (WPARAM)L"xmRefreshTask", 0); return ret; } @@ -3993,9 +3965,8 @@ if (filename == L"" || saveas) { xaserverarg arg ; - arg.AddArg(L"src", myurl); - OpenWindow(L"dev:xpage[trade.document.saveas.vx]", cast(arg as int)); + OpenWindow(L"dev:xpage[trade.document.saveas.vx]", arg); if (arg.GetArgString(L"result") == L"ok") { sfilename = arg.GetArgString(L"filename"); @@ -4009,7 +3980,7 @@ xstring sguid = publiccode::GetGuid(); xstring sname = sguid; xstring str = sname.mid(0, 2); - str = str.upper(); + str = str.toUpper(); xstring suri = L"attachment" + str; int ret = xaserver::UploadData(suri, sguid + L".jpg", content); if (ret < 0) @@ -4019,7 +3990,6 @@ } xml x ; - xaserverarg args ; args.setNativePointer(args.CreateInstance()); args.AddArg(L"myurl", myurl); @@ -4040,7 +4010,7 @@ else { filename = sfilename; - win32::SetWindowText(GetHWND(), L"鎶ヤ环鏂囦欢:" + filename); + SetWindowText(GetHWND(), L"鎶ヤ环鏂囦欢:" + filename); alert(x.text()); } @@ -4049,11 +4019,11 @@ int SendCtrlCmd(xcontrol xc, xstring cmd) { - win32::SendMessage(xc.GetId(), 0x401, cmd, 0); + SendMessage(xc.GetHWND(), 0x401, cmd, 0); return 1; } - int OnCellClicked(ref TNotifyEvent evt, int p) + int OnCellClicked(TEvent*, LPARAM p) { ref DWNMHDR dwhdr = cast(evt.pnmh as ref DWNMHDR); int row = dwhdr.row; @@ -4259,7 +4229,7 @@ } - int OnCellClicked1(ref TNotifyEvent evt, int p) + int OnCellClicked1(TEvent*, LPARAM p) { ref DWNMHDR dwhdr = cast(evt.pnmh as ref DWNMHDR); int row = dwhdr.row; diff --git a/jrj/xframe/adt/xarray.hpp b/jrj/xframe/adt/xarray.hpp new file mode 100644 index 0000000..63346d6 --- /dev/null +++ b/jrj/xframe/adt/xarray.hpp @@ -0,0 +1,128 @@ +#pragma once + +#include "system/base.hpp" +#include "wobject/xobject.hpp" +#include "wobject/xstring.hpp" + +template<class T> +class xarray : public xobject +{ +public: + xarray(length_(0), capacity_(0),itemms(nullptr){ + } +public: + xarray*push_back(T t) + { + sure_space(); + + items[length_] = t; + ++length_; + return this; + } + + xarray* pop_back() + { + if (length() > 0) + erase(length() - 1); + return this; + } + + xarray* erase(int index) + { + if (index < 0 || index > length_ - 1) + { + //throw("..."); + return this; + } + //move data + for (int i = index; i < length_ - 1; i++)items[i] = items[i + 1]; + --length_; + return this; + } + + xarray* insert_before(int index, T t) + { + sure_space(); + + if (index < 0) + { + for (int i = 0; i < length_ - 1; i++)items[i] = items[i + 1]; + items[0] = t; + return this; + } + if (index >= length_) + { + items[length_] = t; + ++length_; + } + return this; + } + + xarray* insert_after(int index, T t) + { + return insert_before(index + 1, t); + } + + T back() + { + if (length_) + return items[length_ - 1]; + return 0; + } + + T front() + { + if (length_) + return items[0]; + return 0; + } + + int length() + { + return length_; + } + + T item(int index) + { + if (index >= 0 && index < length_) return items[index]; + return 0; + } + + int find(T t) + { + for (int i = 0; i < length_; i++) + { + if (items[i] == t) return i; + } + return -1; + } +private: + bool sure_space() + { + if (length_ == capacity_) + { + if (!items) + { + items = new T[2]; + capacity_ = 2; + } + else + { + capacity_ = capacity_ * 2; + T* temp = new T[capacity_]; + //可以优化为拷贝操作 + for (int i = 0; i < length_; ++i) + { + temp[i] = items[i]; + } + delete items; + items = temp; + } + } + return true; + } +private: + T* items; + int length_; + int capacity_; +}; \ No newline at end of file diff --git a/jrj/xframe/kobject/kapp.hpp b/jrj/xframe/kobject/kapp.hpp index 1e6619a..567a03c 100644 --- a/jrj/xframe/kobject/kapp.hpp +++ b/jrj/xframe/kobject/kapp.hpp @@ -30,5 +30,6 @@ static int trace(LPCTSTR pstr); public: int Run(); + }; }} \ No newline at end of file diff --git a/jrj/xframe/win32/win.hpp b/jrj/xframe/win32/win.hpp index e32f9d2..1fca858 100644 --- a/jrj/xframe/win32/win.hpp +++ b/jrj/xframe/win32/win.hpp @@ -29,12 +29,6 @@ #define WINAPI __stdcall -#define SendMessage SendMessageW -#define PostMessage PostMessageW -#define GetWindowLong GetWindowLongW -#define SetWindowLong SetWindowLongW -#define MessageBox MessageBoxW - extern "C" { void WINAPI SysFreeString(BSTR str);//OleAut32.dll @@ -111,9 +105,20 @@ int WINAPI GetTempPathW(int NAME_LEN,string & OutPath) ;//native from "kernel32.dll" alias "GetTempPathW"; int WINAPI GetModuleHandleW(string lpModuleName) ;//native from "kernel32.dll" alias "GetModuleHandleW"; - int WINAPI GetModuleFileName(int hModule ,string & lpFileName ,int nSize ) ;//native from "kernel32.dll" alias "GetModuleFileName"; + int WINAPI GetModuleFileNameW(int hModule ,string lpFileName, int nSize);//native from "kernel32.dll" alias "GetModuleFileNameW"; void WINAPI GetLocalTime(SYSTEMTIME& lpSystemTime) ;//native from "kernel32.dll" alias "GetLocalTime"; + int WINAPI PathRemoveFileSpecW(xstring lpFileName);// native from "shlwapi.dll" alias "PathRemoveFileSpecW"; + } +#define SendMessage SendMessageW +#define PostMessage PostMessageW +#define GetWindowLong GetWindowLongW +#define SetWindowLong SetWindowLongW +#define MessageBox MessageBoxW +#define GetModuleFileName GetModuleFileNameW +#define PathRemoveFileSpec PathRemoveFileSpecW +#define SetWindowText SetWindowTextW +#define GetWindowText GetWindowTextW #if 0 namespace win32 @@ -193,5 +198,6 @@ int GetModuleHandleW(string lpModuleName) ;//native from "kernel32.dll" alias "GetModuleHandleW"; int GetModuleFileName(int hModule ,string & lpFileName ,int nSize ) ;//native from "kernel32.dll" alias "GetModuleFileName"; void GetLocalTime(SYSTEMTIME& lpSystemTime) ;//native from "kernel32.dll" alias "GetLocalTime"; + } #endif \ No newline at end of file diff --git a/jrj/xframe/win32/xfile.hpp b/jrj/xframe/win32/xfile.hpp new file mode 100644 index 0000000..aa59820 --- /dev/null +++ b/jrj/xframe/win32/xfile.hpp @@ -0,0 +1,186 @@ +#pragma once + +#include "system/base.hpp" +#include "win.hpp" + +#define CALLBACK __stdcall +#define MAX_PATH 260 +typedef unsigned short WORD; +typedef unsigned int UINT; +typedef char CHAR; +typedef unsigned char BYTE; +typedef wchar_t WCHAR; +typedef void* HANDLE; +typedef const char* LPCSTR; +typedef void* LPVOID; +typedef DWORD* LPDWORD; +typedef const void* LPCVOID; + +typedef void* LPSECURITY_ATTRIBUTES; +typedef UINT_PTR(CALLBACK* LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM); +struct OPENFILENAMEW +{ + DWORD lStructSize; + HWND hwndOwner; + HINSTANCE hInstance; + LPCWSTR lpstrFilter; + LPWSTR lpstrCustomFilter; + DWORD nMaxCustFilter; + DWORD nFilterIndex; + LPWSTR lpstrFile; + DWORD nMaxFile; + LPWSTR lpstrFileTitle; + DWORD nMaxFileTitle; + LPCWSTR lpstrInitialDir; + LPCWSTR lpstrTitle; + DWORD Flags; + WORD nFileOffset; + WORD nFileExtension; + LPCWSTR lpstrDefExt; + LPARAM lCustData; + LPOFNHOOKPROC lpfnHook; + LPCWSTR lpTemplateName; + + void* pvReserved; + DWORD dwReserved; + DWORD FlagsEx; +}; + +//FILETIME结构持有的64位无符号的文件的日期和时间值。头文件: WINDEF.H +struct FILETIME +{ + int dwLowDateTime; // 低 32 位 + int dwHighDateTime; // 高 32 位 +}; + +#if 0 +struct fileinfo : public xstruct +{ + char[128] szFileTitle; //文件的标题名 + int dwFileAttributes; //文件的属性 + FILETIME ftCreationTime; //文件的创建时间 + FILETIME ftLastAccessTime; //文件的最后访问时间 + FILETIME ftLastWriteTime; //文件的最后修改时间 + int nFileSizeHigh; //文件大小的高位双字 + int nFileSizeLow; //文件大小的低位双字 + int dwReserved0; //保留,为0 + int dwReserved1; //保留,为0 +}; +#endif + +typedef struct _WIN32_FIND_DATAW { + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD dwReserved0; + DWORD dwReserved1; + WCHAR cFileName[MAX_PATH]; + WCHAR cAlternateFileName[14]; +} WIN32_FIND_DATAW; + +typedef struct _OVERLAPPED { + ULONG_PTR Internal; + ULONG_PTR InternalHigh; + union { + struct { + DWORD Offset; + DWORD OffsetHigh; + } DUMMYSTRUCTNAME; + LPVOID Pointer; + } DUMMYUNIONNAME; + + HANDLE hEvent; +} OVERLAPPED, * LPOVERLAPPED; + + +#define OFS_MAXPATHNAME 128 +typedef struct _OFSTRUCT { + BYTE cBytes; + BYTE fFixedDisk; + WORD nErrCode; + WORD Reserved1; + WORD Reserved2; + CHAR szPathName[OFS_MAXPATHNAME]; +} OFSTRUCT; + +extern "C" +{ + bool WINAPI GetSaveFileNameW(OPENFILENAMEW &);//native from "comdlg32.dll" alias "GetSaveFileNameW"; + bool WINAPI GetOpenFileNameW(OPENFILENAMEW&);//native from "comdlg32.dll" alias "GetOpenFileNameW"; + + HANDLE WINAPI FindFirstFileW(const WCHAR * lpFileName, WIN32_FIND_DATAW& lpFindFileData); //native from "kernel32.dll" alias "FindFirstFileW"; //根据文件名查找文件,一旦不再需要,应该用FindClose函数关闭这个句柄 + HANDLE WINAPI FindNextFileW(HANDLE hFindFile, WIN32_FIND_DATAW& lpFindFileData); //native from "kernel32.dll" alias "FindNextFileW"; //继续查找FindFirstFile函数搜索后的文件 ,HANDLE hFindFile搜索的文件句柄 函数执行的时候搜索的是此句柄的下一文件。非零表示成功,零表示失败。如不再有与指定条件相符的文件,会将GetLastError设置成ERROR_NO_MORE_FILES + bool WINAPI FindClose(HANDLE hFindFile); //native from "kernel32.dll" alias "FindClose"; //关闭由FindFirstFile函数创建的一个搜索句柄。返回非零表示成功,零表示失败。会设置GetLastError + + int WINAPI CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); //native from "kernel32.dll" alias "CreateFileW"; + int WINAPI OpenFile(LPCSTR lpFileName, OFSTRUCT lpReOpenBuff, UINT wStyle); //native from "kernel32.dll" alias "OpenFile"; + int WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, LONG* lpDistanceToMoveHigh, DWORD dwMoveMethod); //native from "kernel32.dll" alias "SetFilePointer"; + int WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); //native from "kernel32.dll" alias "ReadFile"; + int WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); //native from "kernel32.dll" alias "ReadFile"; + int WINAPI CloseHandle(HANDLE hFile); //native from "kernel32.dll" alias "CloseHandle"; + int WINAPI GetFileSize(HANDLE hFile, int lpFileSizeHigh); //native from "kernel32.dll" alias "GetFileSize"; + int WINAPI GetKeyState(HANDLE nVirtKey); //native from "user32.dll" alias "GetKeyState"; +} + +class xfile +{ + bool WINAPI GetSaveFileName(OPENFILENAMEW& OpenFileName) + { + return GetSaveFileNameW(OpenFileName); + } + bool WINAPI GetOpenFileName(OPENFILENAMEW& SaveFileName) + { + return GetOpenFileName(SaveFileName); + } + + HANDLE WINAPI FindFirstFile(const WCHAR* lpFileName, WIN32_FIND_DATAW& lpFindFileData) + { + return FindFirstFileW(lpFileName, lpFindFileData); + } + + HANDLE WINAPI FindNextFile(HANDLE hFindFile, WIN32_FIND_DATAW& lpFindFileData) + { + return FindNextFileW(hFindFile, lpFindFileData); + } + bool WINAPI FindClose(HANDLE hFindFile) + { + return FindClose(hFindFile); + } + + int WINAPI CreateFile(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) + { + return CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); + } + + int WINAPI OpenFile(LPCSTR lpFileName, OFSTRUCT lpReOpenBuff, UINT wStyle) + { + return OpenFile(lpFileName, lpReOpenBuff, wStyle); + } + int WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, LONG* lpDistanceToMoveHigh, DWORD dwMoveMethod) + { + return SetFilePointer(hFile, lDistanceToMove, lpDistanceToMoveHigh, dwMoveMethod); + } + int WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) + { + return ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped); + } + int WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) + { + return WriteFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped); + } + int WINAPI CloseHandle(HANDLE hFile) + { + return CloseHandle(hFile); + } + int WINAPI GetFileSize(HANDLE hFile, int lpFileSizeHigh) + { + return GetFileSize(hFile, lpFileSizeHigh); + } + int WINAPI GetKeyState(HANDLE nVirtKey) + { + return GetKeyState(nVirtKey); + } +}; diff --git a/jrj/xframe/wobject/xaserver.hpp b/jrj/xframe/wobject/xaserver.hpp index fac0301..0378f58 100644 --- a/jrj/xframe/wobject/xaserver.hpp +++ b/jrj/xframe/wobject/xaserver.hpp @@ -170,9 +170,9 @@ return kxaserver::UploadEx((LPTSTR)pUri, (LPTSTR)pName,m_hWnd, (LPTSTR)pSource,bCompress); } - static int Upload(LPTSTR pUri,LPTSTR pName,HWND m_hWnd,LPTSTR pSource=NULL,BOOL bCompress=false) + static int Upload(LPCTSTR pUri,LPCTSTR pName,HWND m_hWnd,LPCTSTR pSource=NULL,BOOL bCompress=false) { - return kxaserver::Upload(pUri,pName,m_hWnd,pSource,bCompress); + return kxaserver::Upload((LPTSTR)pUri,(LPTSTR)pName,m_hWnd, (LPTSTR)pSource,bCompress); } static int Upload(LPCTSTR pUri,LPCTSTR pName,LPCTSTR pPath,HWND m_hWnd,LPCTSTR pSource=NULL,BOOL bCompress=false) @@ -188,11 +188,11 @@ { return kxaserver::UploadFile((LPTSTR)pUri,(LPTSTR)pName,m_hWnd,(LPTSTR)pSource,bCompress); } - static int __DeleteFile(LPTSTR pName) + static int DeleteFile(LPTSTR pName) { return kxaserver::__DeleteFile(pName); } - static int __CreateDirectory(LPCTSTR pName) + static int CreateDirectory(LPCTSTR pName) { return kxaserver::__CreateDirectory((LPTSTR)pName); } diff --git a/jrj/xframe/wobject/xint.hpp b/jrj/xframe/wobject/xint.hpp index 02ad9fd..0a27cfc 100644 --- a/jrj/xframe/wobject/xint.hpp +++ b/jrj/xframe/wobject/xint.hpp @@ -18,5 +18,5 @@ public: operator int() { return value; } double toDouble() { return (double)value; } - xstring toString() { return (xstring(value); } + xstring toString() { return xstring(value); } }; \ No newline at end of file diff --git a/jrj/xframe/wobject/xutil.hpp b/jrj/xframe/wobject/xutil.hpp index e20ef30..8ce0f0e 100644 --- a/jrj/xframe/wobject/xutil.hpp +++ b/jrj/xframe/wobject/xutil.hpp @@ -53,4 +53,20 @@ return Hxsoft::XUtil::FormatDecimalString(str, format, bfree); } +public: + static xstring GetModulePath() + { + wchar_t buf[255]; + GetModuleFileName(0, buf, 255); + PathRemoveFileSpec(buf); + return xstring(buf); + } + + static xstring GetModuleTmpPath() + { + xstring tmp = GetModulePath() + L"\\Temp"; + xaserver::CreateDirectory(tmp); + return tmp; + } + }; \ No newline at end of file -- Gitblit v1.9.3