2016年2月18日 星期四

Basic access authentication

For detail information, we can check https://en.wikipedia.org/wiki/Basic_access_authentication


In the context of an HTTP transaction, basic access authentication is a method for an HTTP user agent to provide a user name and password when making a request.
 

Client side

When the user agent wants to send the server authentication credentials it may use the Authorization field.[7]
The Authorization field is constructed as follows:[8][9][10]
  1. The username and password are combined into a string separated by a colon, e.g.: username:password
  2. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line.
  3. The authorization method and a space i.e. "Basic " is then put before the encoded string.
For example, if the user agent uses Aladdin as the username and OpenSesame as the password then the field is formed as follows:
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

For Base64 encoding detail information, it can check https://en.wikipedia.org/wiki/Base64.  For Base64 implementation, it can use Convert.ToBase64String with C#, and CryptBinaryToString with C++.



2014年11月1日 星期六

libssh2 for Windows

1. Download the libssh2 source code from http://www.libssh2.org/.  Try to build Win32 directory.
2. Download Win32 OpenSSL v1.0.1j from https://slproweb.com/products/Win32OpenSSL.html.
3. Download zlib.lib from http://www.zlib.net/
4. During build, it will meet unresolved external symbol problem.  Then try
Go to ‘test’ project properties C/C++->Preprocessor->Preprocessor Definitions and remove ‘LIBSSH2_WIN32‘

2014年9月28日 星期日

Windows windbg -- lm (List module)

For Windows 8.1 x64 OS, windbg lm command can list Windows module.  It help us to understand Windows driver image location.  There are 3 groups for the drivers.  kdcom.dll, ntoskrnl.exe, hal.dll is one group(FFFFF800xxxxxxxx).  win32k.sys, TSDDD.dll,cdd.dll, and ATMFD.dll is one group(FFFFF960xxxxxxxx).  The others is one group(FFFFF880xxxxxxxx).

0: kd> lm
start             end                 module name
fffff800`00bc3000 fffff800`00bcd000   kdcom      (deferred)
fffff800`02e03000 fffff800`033d4000   nt         (pdb symbols)         
fffff800`033d4000 fffff800`0341d000   hal        (deferred)
fffff880`00c00000 fffff880`00cc0000   CI         (deferred)
fffff880`00cd4000 fffff880`00ce1000   mcupdate_AuthenticAMD   (deferred)
fffff880`00ce1000 fffff880`00cf5000   PSHED      (deferred)
fffff880`00cf5000 fffff880`00d53000   CLFS       (deferred)
fffff880`00d53000 fffff880`00daf000   volmgrx    (deferred)
fffff880`00daf000 fffff880`00dd9000   ataport    (deferred)
fffff880`00dd9000 fffff880`00de4000   msahci     (deferred)
fffff880`00de4000 fffff880`00dfb000   amd_sata   (deferred)
fffff880`00e00000 fffff880`00e0a000   msisadrv   (deferred)
fffff880`00e0a000 fffff880`00e3d000   pci        (deferred)
fffff880`00e3d000 fffff880`00e4a000   vdrvroot   (deferred)
fffff880`00e4a000 fffff880`00e5f000   partmgr    (deferred)
fffff880`00e5f000 fffff880`00e68000   compbatt   (deferred)
fffff880`00e68000 fffff880`00e74000   BATTC      (deferred)
fffff880`00e74000 fffff880`00e89000   volmgr     (deferred)
fffff880`00e89000 fffff880`00e90000   pciide     (deferred)
fffff880`00e90000 fffff880`00ea0000   PCIIDEX    (deferred)
fffff880`00ea0000 fffff880`00eba000   mountmgr   (deferred)
fffff880`00eba000 fffff880`00ec3000   atapi      (deferred)
fffff880`00ec8000 fffff880`00f8a000   Wdf01000   (deferred)
fffff880`00f8a000 fffff880`00f9a000   WDFLDR     (deferred)
fffff880`00f9a000 fffff880`00ff1000   ACPI       (deferred)
fffff880`00ff1000 fffff880`00ffa000   WMILIB     (deferred)
fffff880`01025000 fffff880`01087000   storport   (deferred)
fffff880`01087000 fffff880`01094000   amd_xata   (deferred)
fffff880`01094000 fffff880`0109f000   amdxata    (deferred)
fffff880`0109f000 fffff880`010eb000   fltmgr     (deferred)
fffff880`010eb000 fffff880`0115c000   SYMDS64    (deferred)
fffff880`0115c000 fffff880`01170000   fileinfo   (deferred)
fffff880`01170000 fffff880`011bc000   volsnap    (deferred)
fffff880`011bc000 fffff880`011f6000   rdyboost   (deferred)
fffff880`01200000 fffff880`0125e000   msrpc      (deferred)
fffff880`0125e000 fffff880`012d0000   cng        (deferred)
fffff880`012f0000 fffff880`013d4000   SYMEFA64   (deferred)
fffff880`013d4000 fffff880`013e0040   PxHlpa64   (deferred)
fffff880`01400000 fffff880`0141a000   ksecdd     (deferred)
fffff880`0141a000 fffff880`0142b000   pcw        (deferred)
fffff880`0142b000 fffff880`01435000   Fs_Rec     (deferred)
fffff880`01453000 fffff880`015f4000   Ntfs       (deferred)
fffff880`01600000 fffff880`01649000   fwpkclnt   (deferred)
fffff880`0164b000 fffff880`0173d000   ndis       (deferred)
fffff880`0173d000 fffff880`0179d000   NETIO      (deferred)
fffff880`0179d000 fffff880`017c8000   ksecpkg    (deferred)
fffff880`017c8000 fffff880`017d0000   spldr      (deferred)
fffff880`017d0000 fffff880`017e2000   mup        (deferred)
fffff880`017e2000 fffff880`017eb000   hwpolicy   (deferred)
fffff880`01802000 fffff880`019ff000   tcpip      (deferred)
fffff880`01a27000 fffff880`01a61000   fvevol     (deferred)
fffff880`01a61000 fffff880`01a77000   disk       (deferred)
fffff880`01a77000 fffff880`01aa7000   CLASSPNP   (deferred)
fffff880`01ae9000 fffff880`01b13000   cdrom      (deferred)
fffff880`01b13000 fffff880`01b1c000   Null       (deferred)
fffff880`01b1c000 fffff880`01b23000   Beep       (deferred)
fffff880`01b23000 fffff880`01b33000   RegHiveRecovery   (deferred)
fffff880`01b33000 fffff880`01b41000   vga        (deferred)
fffff880`01b41000 fffff880`01b66000   VIDEOPRT   (deferred)
fffff880`01b66000 fffff880`01b76000   watchdog   (deferred)
fffff880`01b76000 fffff880`01b7f000   RDPCDD     (deferred)
fffff880`01b7f000 fffff880`01b88000   rdpencdd   (deferred)
fffff880`01b88000 fffff880`01b91000   rdprefmp   (deferred)
fffff880`01b91000 fffff880`01b9c000   Msfs       (deferred)
fffff880`01b9c000 fffff880`01bad000   Npfs       (deferred)
fffff880`01bad000 fffff880`01bcb000   tdx        (deferred)
fffff880`01bcb000 fffff880`01bd8000   TDI        (deferred)
fffff880`01bd8000 fffff880`01bf0000   BTHUSB     (deferred)
fffff880`03a00000 fffff880`03a20000   bthpan     (deferred)
fffff880`03a20000 fffff880`03a44e00   btath_rcp   (deferred)
fffff880`03a45000 fffff880`03aac000   btath_a2dp   (deferred)
fffff880`03ac8000 fffff880`03b54000   bthport    (deferred)
fffff880`03b54000 fffff880`03b65000   WinUSB     (deferred)
fffff880`03b65000 fffff880`03ba5000   RtsUStor   (deferred)
fffff880`03ba5000 fffff880`03bd1000   rfcomm     (deferred)
fffff880`03bd1000 fffff880`03be1000   BthEnum    (deferred)
fffff880`03c14000 fffff880`03c9d000   afd        (deferred)
fffff880`03c9d000 fffff880`03ce2000   netbt      (deferred)
fffff880`03ce2000 fffff880`03ceb000   wfplwf     (deferred)
fffff880`03ceb000 fffff880`03d11000   pacer      (deferred)
fffff880`03d11000 fffff880`03d27000   vwififlt   (deferred)
fffff880`03d27000 fffff880`03d36000   netbios    (deferred)
fffff880`03d36000 fffff880`03d51000   wanarp     (deferred)
fffff880`03d51000 fffff880`03d65000   termdd     (deferred)
fffff880`03d65000 fffff880`03dcc000   SYMNETS    (deferred)
fffff880`03dcc000 fffff880`03df9200   usbvideo   (deferred)
fffff880`03e00000 fffff880`03e76000   IDSVia64   (deferred)
fffff880`03e76000 fffff880`03e85000   discache   (deferred)
fffff880`03e85000 fffff880`03ea3000   dfsc       (deferred)
fffff880`03ea3000 fffff880`03eb4000   blbdrive   (deferred)
fffff880`03eb4000 fffff880`03ec7000   dump_dumpfve   (deferred)
fffff880`03ed5000 fffff880`03f0b000   SYMEVENT64x86   (deferred)
fffff880`03f0b000 fffff880`03f38000   Ironx64    (deferred)
fffff880`03f38000 fffff880`03f4e000   SRTSPX64   (deferred)
fffff880`03f4e000 fffff880`03f9f000   rdbss      (deferred)
fffff880`03f9f000 fffff880`03fab000   nsiproxy   (deferred)
fffff880`03fab000 fffff880`03fb6000   mssmbios   (deferred)
fffff880`03fb6000 fffff880`03fd3000   usbccgp    (deferred)
fffff880`03fd3000 fffff880`03ffdc40   CtClsFlt   (deferred)
fffff880`04000000 fffff880`0404f000   atikmpag   (deferred)
fffff880`0404f000 fffff880`04070000   raspptp    (deferred)
fffff880`04070000 fffff880`040b3000   ks         (deferred)
fffff880`040b3000 fffff880`040c5000   umbus      (deferred)
fffff880`040c5000 fffff880`041b0000   BHDrvx64   (deferred)
fffff880`041b0000 fffff880`041d6000   tunnel     (deferred)
fffff880`041d6000 fffff880`041ee000   amdhub30   (deferred)
fffff880`041ee000 fffff880`041fc000   monitor    (deferred)
fffff880`04200000 fffff880`0426a000   Rt64win7   (deferred)
fffff880`0426a000 fffff880`0428e000   rasl2tp    (deferred)
fffff880`0428e000 fffff880`04299000   btath_bus   (deferred)
fffff880`042a0000 fffff880`04394000   dxgkrnl    (deferred)
fffff880`04394000 fffff880`043da000   dxgmms1    (deferred)
fffff880`043da000 fffff880`043fe000   HDAudBus   (deferred)
fffff880`04a00000 fffff880`04a2f000   ndiswan    (deferred)
fffff880`04a2f000 fffff880`04a4a000   raspppoe   (deferred)
fffff880`04a4a000 fffff880`04a64000   rassstp    (deferred)
fffff880`04a65000 fffff880`0538c000   atikmdag   (deferred)
fffff880`0538c000 fffff880`053e6000   Apfiltr    (deferred)
fffff880`053e6000 fffff880`053fa000   amdiox64   (deferred)
fffff880`05600000 fffff880`056a6000   peauth     (deferred)
fffff880`056b9000 fffff880`0571c000   btath_hcrp   (deferred)
fffff880`0571c000 fffff880`0572b000   btath_flt   (deferred)
fffff880`0572b000 fffff880`0573e000   btath_lwflt   (deferred)
fffff880`0573e000 fffff880`05761000   luafv      (deferred)
fffff880`05761000 fffff880`05776000   lltdio     (deferred)
fffff880`05776000 fffff880`057c9000   nwifi      (deferred)
fffff880`057c9000 fffff880`057dc000   ndisuio    (deferred)
fffff880`057dc000 fffff880`057f4000   rspndr     (deferred)
fffff880`05800000 fffff880`05804500   CmBatt     (deferred)
fffff880`05805000 fffff880`0581a000   amdppm     (deferred)
fffff880`0581a000 fffff880`0582a000   CompositeBus   (deferred)
fffff880`0582a000 fffff880`05840000   AgileVpn   (deferred)
fffff880`05840000 fffff880`0584c000   ndistapi   (deferred)
fffff880`0584c000 fffff880`0584d480   swenum     (deferred)
fffff880`05851000 fffff880`05cdb000   bcmwl664   (deferred)
fffff880`05cdb000 fffff880`05ce8000   vwifibus   (deferred)
fffff880`05ce8000 fffff880`05d18000   amdxhc     (deferred)
fffff880`05d18000 fffff880`05d19f00   USBD       (deferred)
fffff880`05d1a000 fffff880`05d29000   usbfilter   (deferred)
fffff880`05d29000 fffff880`05d34000   usbohci    (deferred)
fffff880`05d34000 fffff880`05d8a000   USBPORT    (deferred)
fffff880`05d8a000 fffff880`05d9b000   usbehci    (deferred)
fffff880`05d9b000 fffff880`05db9000   i8042prt   (deferred)
fffff880`05db9000 fffff880`05dc8000   kbdclass   (deferred)
fffff880`05dc8000 fffff880`05dd7000   mouclass   (deferred)
fffff880`05dd7000 fffff880`05df7000   sdbus      (deferred)
fffff880`05df7000 fffff880`05e00000   wmiacpi    (deferred)
fffff880`05e00000 fffff880`05e0e000   hidusb     (deferred)
fffff880`05e0e000 fffff880`05e27000   HIDCLASS   (deferred)
fffff880`05e27000 fffff880`05e2f080   HIDPARSE   (deferred)
fffff880`05e30000 fffff880`05e3d000   mouhid     (deferred)
fffff880`05e3d000 fffff880`05e49000   Dxapi      (deferred)
fffff880`05e49000 fffff880`05e57000   crashdmp   (deferred)
fffff880`05e57000 fffff880`05e61000   dump_diskdump   (deferred)
fffff880`05e61000 fffff880`05e78000   dump_amd_sata   (deferred)
fffff880`05e82000 fffff880`05edc000   usbhub     (deferred)
fffff880`05edc000 fffff880`05ef1000   NDProxy    (deferred)
fffff880`05ef1000 fffff880`05f11000   AtihdW76   (deferred)
fffff880`05f11000 fffff880`05f4e000   portcls    (deferred)
fffff880`05f4e000 fffff880`05f70000   drmk       (deferred)
fffff880`05f70000 fffff880`05f75200   ksthunk    (deferred)
fffff880`05f76000 fffff880`05ff9000   stwrt64    (deferred)
fffff880`07623000 fffff880`076eb000   HTTP       (deferred)
fffff880`076eb000 fffff880`07709000   bowser     (deferred)
fffff880`07709000 fffff880`07721000   mpsdrv     (deferred)
fffff880`07721000 fffff880`0774e000   mrxsmb     (deferred)
fffff880`0774e000 fffff880`0779c000   mrxsmb10   (deferred)
fffff880`0779c000 fffff880`077bf000   mrxsmb20   (deferred)
fffff880`077bf000 fffff880`077d1000   tcpipreg   (deferred)
fffff880`07c00000 fffff880`07c0b000   secdrv     (deferred)
fffff880`07c0b000 fffff880`07c38000   srvnet     (deferred)
fffff880`07c41000 fffff880`07df6000   rikvm_9EC60124   (deferred)
fffff880`08200000 fffff880`08236000   fastfat    (deferred)
fffff880`08236000 fffff880`0825e000   mrxdav     (deferred)
fffff880`0825e000 fffff880`08294000   WUDFRd     (deferred)
fffff880`08294000 fffff880`082af000   USBSTOR    (deferred)
fffff880`082af000 fffff880`082bc000   LiveKdD    (deferred)
fffff880`082cc000 fffff880`08333000   srv2       (deferred)
fffff880`08333000 fffff880`083c8000   srv        (deferred)
fffff880`083c8000 fffff880`083e1000   WudfPf     (deferred)
fffff960`00090000 fffff960`003a6000   win32k     (deferred)
fffff960`00500000 fffff960`0050a000   TSDDD      (deferred)
fffff960`00640000 fffff960`00667000   cdd        (deferred)
fffff960`00810000 fffff960`00871000   ATMFD      (deferred)

2014年8月18日 星期一

Drag and Drop (OLE)

1. There is the MSDN document introduce it -- http://msdn.microsoft.com/en-us/library/96826a87.aspx 2. There is a document talk about how to implement it. -- http://www.codeproject.com/Articles/840/How-to-Implement-Drag-and-Drop-Between-Your-Progra 3. There is a document talk about CRicheditView with Drag & Drop -- http://computer-programming-forum.com/82-mfc/cad93aec74dd76a3.htm CRichEditView supports OLE drag and drop. It has the interfaces that determines the data it can accept. Therefore, WM_DROPFILES won't be received unless it fails to perform the OLE drag & drop. You can override CRichEditView::QueryAcceptData, which is the actual implementation of IRichEditOleCallback::QueryAcceptData. In QueryAcceptData, return S_FALSE directly. However, this disables the OLE drop/paste operation. You can also handle CRichEditView::QueryAcceptData more elaborately so that specific data can be handled in WM_DROPFILES. You may want to check CRichEditView::QueryAcceptData in viewrich.cpp for more information.

2014年7月12日 星期六

Windbg: How to implement .frame command.

There is the windbg command .frame

.frame (Set Local Context)

The .frame command specifies which local context (scope) is used to interpret local variables or displays the current local context.
.frame [/c] [/r] [FrameNumber] 

There is the function in the dbgeng.dll can help us to implement it.

IDebugSymbols3::SetScopeFrameByIndex method

2013年11月18日 星期一

CoInitializeSecurity call fails with error code RPC_E_TOO_LATE

In the VC++ MFC MDI, the  CoInitializeSecurity call fails with error code RPC_E_TOO_LATE

1. We can check (http://msdn.microsoft.com/en-us/library/windows/desktop/aa394603(v=vs.85).aspx) for WMI troubleshooting.

2. There is the example code in the http://support.microsoft.com/kb/948829

3. The code here (http://www.codeproject.com/Articles/216077/Making-Your-Cplusplus-Code-Robust) can help us solve the WMI execquery problem.

4. Please check http://msdn.microsoft.com/en-us/library/windows/desktop/aa393609(v=vs.85).aspx.  The key point is CoSetProxyBlanket function.

hres = CoSetProxyBlanket(
   pSvc,                        // Indicates the proxy to set
   RPC_C_AUTHN_WINNT,           // RPC_C_AUTHN_xxx
   RPC_C_AUTHZ_NONE,            // RPC_C_AUTHZ_xxx
   NULL,                        // Server principal name 
   RPC_C_AUTHN_LEVEL_CALL,      // RPC_C_AUTHN_LEVEL_xxx 
   RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
   NULL,                        // client identity
   EOAC_NONE                    // proxy capabilities 
);

2013年11月13日 星期三

SetFont for CButton

About the SetFont of the CButton, there is a example in the http://support.microsoft.com/kb/85518/en-us.

class CMyAboutBox : public CDialog
{
   CFont m_font;

   public:
      // Constructor -- This code assumes a dialog box
      // template named "ABOUTDLG" in the application's .RC file.

      CMyAboutBox(CWnd* pParentWnd = NULL) :
         CModalDialog("ABOUTDLG", pParentWnd) {};

      BOOL OnInitDialog();
};

It will be failed, if you put the CFont m_font in the OnInitDialog()

2013年10月13日 星期日

windbg local mode study

It will call dbgeng!LocalLiveKernelTargetInfo::InitDriver and then create kldbgdrv.sys in the c:\Windows\System32 folder.

2013年10月5日 星期六

PCI address to Device manager device description

TCHAR buf[MAX_DEVICE_ID_LEN];  // (Dynamically size this instead?)

PTSTR DriverNameToDeviceDesc (UCHAR bn, UCHAR dn, UCHAR fn, BOOLEAN DeviceId)
{
HDEVINFO  hDevInfo;
    SP_DEVINFO_DATA  DeviceInfoData;
    DWORD  i;
BOOL r;
int j=0;


    //  Create  a  HDEVINFO  with  all  present  devices.      
hDevInfo  =  SetupDiGetClassDevs(NULL,
               0,  //  Enumerator
               0,
               DIGCF_PRESENT    |  DIGCF_ALLCLASSES  );
 
    if  (hDevInfo  ==  INVALID_HANDLE_VALUE)
    {
               //  Insert  error  handling  here.
               return  NULL;
    }
       
    //  Enumerate  through  all  devices  in  Set.
    DWORD  DataT;
    DWORD  buffersize  =  0;
    DeviceInfoData.cbSize  =  sizeof(SP_DEVINFO_DATA);
   
for  (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,
               &DeviceInfoData);i++)
    {
 
           if(SetupDiGetDeviceRegistryProperty(
                       hDevInfo,
                       &DeviceInfoData,
                       SPDRP_BUSNUMBER,
                       &DataT,
                       (PBYTE)buf,
                       MAX_DEVICE_ID_LEN,
                       &buffersize))
  {
  if(buffersize == 4 && (UCHAR) buf[0] == bn)
  {
   if(SetupDiGetDeviceRegistryProperty(
                       hDevInfo,
                       &DeviceInfoData,
                       SPDRP_ADDRESS,
                       &DataT,
                       (PBYTE)buf,
                       MAX_DEVICE_ID_LEN,
                       &buffersize))
{
if (buffersize == 4 && (UCHAR) buf[0] == fn && (UCHAR) buf[2] == dn)
{
if(SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
&DataT,
(PBYTE)buf,
MAX_DEVICE_ID_LEN,
&buffersize))
{
return buf;
}
else
{
SetupDiDestroyDeviceInfoList(hDevInfo);
return NULL;
}
}
}
}
  }
}
    //    Cleanup
    SetupDiDestroyDeviceInfoList(hDevInfo);  
    return  NULL;
}

2013年7月31日 星期三

About the GRID control for the VS MFC

I don't understand why MS don't try to provide a MFC GRID control.  We can try to make CListCtrl to be the Grid control style.  You can refer the MSDN document here (http://msdn.microsoft.com/en-us/library/ms364048(v=vs.80).aspx), but it's not easy.  Anyway, we can use the code (http://www.codeproject.com/Articles/8/MFC-Grid-control-2-27) in the codeproject to be the base and modify it.

2013年5月7日 星期二

Windows AHCI Link power management setting

1. Run Registry Editor (type "regedit" in the search field on the Start Menu).

2. Navigate to "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\0012ee47-9041-4b5d-9b77-535fba8b1442\0b2d69d7-a2a1-449c-9680-f91c70521c60".

3. Change value "Attributes" to 2. At this step you won't have modified ANY functionality in Windows (except for a tiny detail in the power management USER interface), so it's 100% safe.

4. Reboot.

5. Now go to "Power Management" in Control Panel and click "Change plan settings" of your power plan, then click "Change advanced power settings".

6. Expand the "Hard Disk" settings tree. You'll see that now there is and ADDITIONAL setting: "AHCI Link Power Management - HIPM/DIPM". Expand this one.



--------------------------------------------------------------------------------------------------------

The default power setting for Balanced about ALPM (AC,DC).
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\0012ee47-9041-4b5d-9b77-535fba8b1442\0b2d69d7-a2a1-449c-9680-f91c70521c60\DefaultPowerSchemeValues\381b4222-f694-41f0-9685-ff5bb260df2e]
"ACSettingIndex"=dword:00000001
"DCSettingIndex"=dword:00000001


2013年2月17日 星期日

Undocumented windbg command !chkallimg


!chkimg

The !chkimg extension detects corruption in the images of executable files by comparing them to the copy on a symbol store or other file repository.
!chkimg [Options] [-mmw LogFile LogOptions] [Module]

The !chkimg is useful for us to check the memory (code section) corruption problem.  But if you want to check all the images, you can use the command !chkallimg.  The weird thing is that it need to create the temp folder in the c:\ for !chkallimg command.

2013年1月10日 星期四

Windows -- how to send mail in the application

There is a good document to help us about this -- http://zabkat.com/blog/send-emails-with-CDOSYS.htm.  You can get first view about this.  And there is some sample code in the
http://www.experts-exchange.com/Programming/System/Windows__Programming/A_1820-Sending-Email-with-MAPI.html.

The easiest way is mailto..You can check http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx.

The common way is Microsoft MAPI..http://msdn.microsoft.com/en-us/library/windows/desktop/dd296734(v=vs.85).aspx

Anyway..From the MS document..It say..[The use of Simple MAPI is discouraged. It may be altered or unavailable in subsequent versions of Windows.]

Anyway, the MAPI still work in the Win 7/Win 8.  But sometime, it will return MAPI_E_FAILURE.  Then you can check your application UAC setting.  You can check here (http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/63e9f5b2-f5f2-4cf8-bdc2-ca1fad88ebe5).

2013年1月7日 星期一

PHP run executable file in the xampp of Windows

There is the document talk about this -- http://php.net/manual/en/function.exec.php
<?php function execInBackground($cmd) {
    if (
substr(php_uname(), 0, 7) == "Windows"){
        
pclose(popen("start /B ". $cmd, "r")); 
    }
    else {
        
exec($cmd . " > /dev/null &");  
    }
} 
?> 

And there is also another document talk about this -- http://www.somacon.com/p395.php.  In this document , it provide many methods to do this.  And after my try,   pclose(popen("start /B ". " c:\\new\\New2.bat", "r")); is workable.


For more information, you can check http://php.net/manual/en/function.popen.php.

2012年12月28日 星期五

How to create CMFCPropertySheet


1. First, "Project" -> "Class Wizard.."->"Add Class" --> Select "CPropertyPage".  If you select "CMFCPropertyPage", it will get error, when you run it.
2.After class was created,  we replace all "CPropertyPage" by "CMFCPropertyPage".
3. Add CMFCPropertySheet class.  And add the code.
CMySheet.h
public:
CMySheet();
virtual ~CMySheet();
CMyPage m_page1;
CMySheet.cpp
CMySheet::CMySheet()
{
AddPage(&m_page1);
}
4.
        //Cf9Dlg dlg;
CMySheet dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();

-----------------------
1. The first step, we can check http://msdn.microsoft.com/en-us/library/bb981937.aspx about the MSDN CMFCCpropertySheet Class information (Remarks).

2. We can try to find the information in the http://support.microsoft.com/kb/325613/en-us to know how to add the CPropertySheet and CPropertyPage.

3. There is the http://blog.163.com/xu_chao2000/blog/static/277706102010430338431/ for the CMFCPropertySheet and CMFCPropertyPage.  You will need to create new DIALOG resource to add "CPropertyPage" base class, because the Visual studio has the problem to use "CMFCPropertyPage" as the base class.  After add OK, then change it to "CMFCPropertyPage".

4. More information about CMFCPropertySheet -- http://blog.csdn.net/tory75034/article/details/5404061


2012年12月26日 星期三

About National Language Support

The msdn document http://msdn.microsoft.com/en-us/library/dd317708(v=vs.85).aspx .


The National Language Support (NLS) functions permit applications to:
  • Set the locale for the user
  • Identify the language in which the user works
  • Retrieve strings representing times, dates, and other information formatted correctly for the specified language and locale

There is also the http://stackoverflow.com/questions/953416/find-out-the-language-windows-was-installed-as talk about this.  Two ways to get the OS installed language
1. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Language\InstallLanguage which returns a four digit language code.
2. The Win32 function is GetSystemDefaultUILanguage() http://msdn.microsoft.com/en-us/library/dd318123(VS.85).aspx.

1. Locale IDs, Input Locales, and Language Collections for Windows XP and Windows Server 2003.
http://msdn.microsoft.com/en-us/goglobal/bb895996.aspx.  

2. Re: How to translate the LANGID into strings. http://www.tech-archive.net/Archive/VisualStudio/microsoft.public.vstudio.general/2004-08/0250.html

 TCHAR szName[100]; 
        if ( 0 != GetLocaleInfo( MAKELCID( MAKELANGID( 0x411, 0 ),
SORT_DEFAULT ),
                LOCALE_SENGLANGUAGE,
                szName, 100 ) )
        {
                printf( szName );
        } 




2012年11月7日 星期三

New a Dialog with CEdit and initial string problem

I want to DoModal() a new dialog with a CEdit, and there is one initial string inside the CEdit.  It's not easy to put  the string in the CEdit and show it when DoModal().  Anyway, the web link (http://stackoverflow.com/questions/11715888/domodal-does-not-show-dialog-but-does-its-work ) show us how to do it.

2012年11月5日 星期一

HTML can't use WMI(Windows Management Instrumentation)?

It's a Microsoft Windows technology for application easy to get the system information and communicate with the kernel driver.  For some information about WMI, please check http://msdn.microsoft.com/en-us/library/windows/desktop/aa394582(v=vs.85).aspx


Purpose

Windows Management Instrumentation (WMI) is the infrastructure for management data and operations on Windows-based operating systems. You can write WMI scripts or applications to automate administrative tasks on remote computers but WMI also supplies management data to other parts of the operating system and products, for example System Center Operations Manager, formerly Microsoft Operations Manager (MOM), or Windows Remote Management (WinRM).


You can check http://msdn.microsoft.com/en-us/library/windows/desktop/aa384642(v=vs.85).aspx to know "About WMI".  We can use VBscript to get the WMI information.  But anyway, we can't use HTML to get the WMI information, and it seems only ASP can use WMI.

If we can use the HTML with VBScript page to read WMI information, it will be very powerful.  But maybe it will also get some security concern.

2012年11月3日 星期六

Putting Controls On Toolbars

You can learn how to add combo box into toolbar by  http://msdn.microsoft.com/en-us/library/bb983718.aspx in the MFC project.

There is also the information in the http://msdn.microsoft.com/en-us/library/bb982770.aspx (
CMFCToolBarComboBoxButton Class).  It also show some code in the Visual Studio Demo sample of the MFC sample codes.  You can build the code and play it.

To add a combo box button to a toolbar, follow these steps:
1. Reserve a dummy resource ID for the button in the parent toolbar resource.
2. Construct a CMFCToolBarComboBoxButton object.
3. In the message handler that processes the AFX_WM_RESETTOOLBAR message, replace the dummy button with the new combo box button by usingCMFCToolBar::ReplaceButton.

But anyway, it can't work.  It take me several days to check this problem.  After all, I find we can add m_wndToolBar.ResetAll (); in the SHOWMESSAGE or SIZE message to solve this problem.

2012年10月20日 星期六

ACPICA

ACPI is the basic infrastructure for the Windows and Linux now.  It's the interface for the BIOS and OS.
If you want to study more about the ACPI structure, you should also study https://www.acpica.org


The ACPI Component Architecture Project

line
The ACPI Component Architecture (ACPICA) project provides an operating system (OS)-independent reference implementation of the Advanced Configuration and Power Interface Specification (ACPI). It can be easily adapted to execute under any host OS. The ACPICA code is meant to be directly integrated into the host OS as a kernel-resident subsystem. Hosting the ACPICA subsystem requires no changes to the core ACPICA code. Instead, a small OS-specific interface layer is written specifically for each host OS in order to interface the ACPICA code to the native OS services.


You can download the ACPICA windows source code in the https://www.acpica.org/downloads/source_code.php.  You can build it by Visual studio and play it.

But the iASL(ASLCompiler) is more complex to build it.  And it will need 

For iASL, these versions of Flex and Bison are required:
flex: version 2.5.4 or greater
bison: version 2.4.1 or greater

Please download and setup flex and bison from  http://gnuwin32.sourceforge.net/.
You can install the bison and flex in the C:\GnuWin32.

After all, you will need to m4.exe and regex2.dll to the .\acpica\generate\msvc9 to build it OK.