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(), 07) == "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 );
        }