Reading EPWING dictionaries with Dicregate

1,Obtain any EPWING dictionaries. 2,Open Dicregate.exe 3,Select [Dictionary]->[Add Dictionary]->[Electronic Dictionary] 4,Choose the dictionary folder, the folder that includes a file named “CATALOGS”

Published
Categorized as Windows

How to use VB regex in VC6

1,Open “OLE/COM object viewer” from Tool menu of VC6. 2,Find “Microsoft VBScript Regular Expressions 5.5” under “Type Libraries”. 3, Double click the node to open with “ITypeLib Viewer”. 4, Choose “Save As” and save as “vbscript.IDL”. 5, Run “midl vbscript.idl” in Command Propmt. midl.exe is typically located under “C:\Program Files\Microsoft Visual Studio\VC98\Bin”. This creates “vbscript.tlb”.… Continue reading How to use VB regex in VC6

How to create a C++ function that can take argment of both char* and wchar_t*

Source. Create a traits class that is used as specialized template. Specialize it for char and wchar_t. Generic template is not defined because this function is only for char and wchar_t. #include <wchar.h> #include <stdio.h>   template<typename T> struct kansuu_traits; template<> struct kansuu_traits<char> { static FILE* open(const char* p) { return fopen(p, "r"); } };… Continue reading How to create a C++ function that can take argment of both char* and wchar_t*

How to move file to a trash

Use SHFileOperation(). #include <windows.h> #include <tchar.h> #include <assert.h> #include <malloc.h> #include "SHDeleteFile.h"   BOOL SHDeleteFile(LPCTSTR lpFile) { size_t len = _tcslen(lpFile); if(!lpFile || lpFile[0]==0 || len <= 3) return FALSE;   // only fullpath allowed do { #ifndef UNICODE if (IsDBCSLeadByte((BYTE)lpFile[0])) return FALSE; #endif   if( lpFile[0]==_T(’\\’) && lpFile[1]==_T(’\\’) ) break;   if( lpFile[1] ==… Continue reading How to move file to a trash

System global variable in win32

class CSessionGlobalBool { public: explicit CSessionGlobalBool(LPCSTR pName) { m_pName = (LPSTR)LocalAlloc(LMEM_FIXED, lstrlenA(pName)+sizeof(char)); lstrcpy(m_pName, pName); } ~CSessionGlobalBool(){ LocalFree(m_pName); }   operator bool() { return get(); }   operator =(const bool b) { HANDLE h = CreateEvent(NULL, TRUE, FALSE, m_pName);   if(b) SetEvent(h); else ResetEvent(h); } operator =(const CSessionGlobalBool& sgb) { *this = sgb.get(); } private: bool… Continue reading System global variable in win32

Add a debug console to your windows gui application

Call AllocConsole() at the beginning of your application. Only one console can be allocated for a process. Next, call WriteConsole to show a text. void CMyApp::LogDebug(LPCSTR p) { if(m_bAppDebug) { DWORD d; WriteConsoleA( GetStdHandle(STD_OUTPUT_HANDLE), (CONST VOID *)p, strlen(p), &d, NULL ); WriteConsoleA( GetStdHandle(STD_OUTPUT_HANDLE), (CONST VOID *)"\r\n", 2, &d, NULL );   } }void CMyApp::LogDebug(LPCSTR p)… Continue reading Add a debug console to your windows gui application

Show a “We are Busy” page when your server is too busy by using PHP

If you are apache fan. You shold have many virtual host in your apache conf. But after your site getting popular, sometimes your server can not handle all request and your visitor will have to wait in front of the browser. I could not find a nice solution for that so created one. First, create… Continue reading Show a “We are Busy” page when your server is too busy by using PHP

busyrebooter

I wanted to reboot my ubuntu server when it got very busy state. After trying monit which I think this software has such function, I realize this is a monitoring tool and does not have a such function. That why I created very simple app ‘busyrebooter’. /proc/loadavg shows the busy state. $ cat /proc/loadavg 0.36… Continue reading busyrebooter