不知是安托華的運氣比較好,還是汽車專賣店的品質其實比大賣場的品質能夠好一點。個人覺得
大賣場因為要上架費、管銷費用等,品質先不論有沒有顧到,至少賣家的利潤一定非常低。至於汽車精品店的通路我就不怎麼清楚了。不知是否會在Cost down下犧牲品質。
接下來的接力的長期雨刷追蹤是Tido軟骨雨刷,這是Made in Taiwan的喔。希望能打敗大陸製造的雨刷。
#pragma once
/**
This is the Mass Storage Device Class Library.
Support Help Function to Mass Storage Class.
*/
class CMassStorage
{
public:
CMassStorage(void);
~CMassStorage(void);
/**
Identify a volumn name is exist or not.
\param volname input volumn name
\return true if exist, 0 do not exist.
*/
int isVolumnNameExist(const CString & volname);
/**
Overloaded help function, to supply more argument
\param volman to be identify
\param drv driver letter if the identified voluman exist.
\return true if exist, 0 do not exist.
*/
int isVolumnNameExist(const CString & volname, CString & drv);
int getUSBMsc(void);
};
#include "StdAfx.h"
#include "MassStorage.h"
#include
#include
#include
CMassStorage::CMassStorage(void)
{
}
CMassStorage::~CMassStorage(void)
{
}
int CMassStorage::isVolumnNameExist(const CString & volname)
{
CString dummyDrv;
return isVolumnNameExist(volname, dummyDrv);
}
int CMassStorage::isVolumnNameExist(const CString & volname, CString & drv)
{
TCHAR disk[MAX_PATH]= _T("C:\\");
TCHAR drvltr; // driver letter
TCHAR buf[MAX_PATH];
// scan the disk from C to Z
for (drvltr = 'C'; drvltr <= 'Z'; drvltr++) {
disk[0] = drvltr;
DWORD dummy;
if (GetVolumeInformation(disk, buf, MAX_PATH, &dummy, &dummy, &dummy, NULL, 0)) {
// the driver exist, check the logical volname.
if (volname.CompareNoCase(buf) == 0) {
drv = disk;
return TRUE;
}
}
}
return FALSE;
}
/**
Return the USB mass storage device number
If there are any errors, the returned USB number is still 0.
This function check the device identify if prefixed by "USBSTOR"
\return number of USB mass storage device.
*/
/**
For other GuidClass, search Microsoft for "System-Supplied Device Setup Classes"
*/
DEFINE_GUID(driverGuidConst, 0x4d36e967, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18);
int CMassStorage::getUSBMsc(void)
{
HDEVINFO hdevinfo;
GUID driverGuid = driverGuidConst;
int nousb = 0;
const static WCHAR USB_MASS[]=_T("USBSTORE");
// Get the device setup class handler, for disk driver.
if (INVALID_HANDLE_VALUE != (hdevinfo = SetupDiGetClassDevs(&driverGuid, NULL, NULL, DIGCF_PRESENT ))) {
// Retrieve every instance of this class.
int index = 0;
SP_DEVINFO_DATA data;
data.cbSize = sizeof(SP_DEVINFO_DATA);
while (SetupDiEnumDeviceInfo(hdevinfo, index, &data)) {
ULONG buflen;
// Get the size of device ID buffer.
if (CR_SUCCESS == CM_Get_Device_ID_Size(&buflen, data.DevInst, 0)) {
// if the device is exist, then buflen > 0.
if (buflen > 0) {
WCHAR * buf = new WCHAR[buflen];
CM_Get_Device_ID(data.DevInst, buf, buflen, 0);
if (0 == wcsncmp(USB_MASS, buf, sizeof(USB_MASS)/sizeof(WCHAR))) {
nousb++;
}
delete buf;
}
}
index++;
}
// must free the handle to device information.
SetupDiDestroyDeviceInfoList(hdevinfo);
}
return nousb;
}
<link href="http://double.myweb.hinet.net/web/prettify.css"
type="text/css" rel="stylesheet" />
<script type="text/javascript"
src="http://double.myweb.hinet.net/web/prettify.js">
</script>
<body onload="prettyPrint()"> ......</body>
<pre class="prettyprint lang-html">...</pre>
int rega _at_ 0x800; // 這是fixed address hardware register
rega = 0x55;
_nop_();
rega = 0x80;
rega = 0x55;
rega = 0x80;
rega = 0x80;
volatile int rega _at_ 0x800; // 這是fixed address hardware register
rega = 0x55;
rega = 0x80;
const int bufSize = 512;
const int bufSize; //compiler error here
const int minSalary; // 什麼都漲,只有薪水是固定的
int * pSalary = &minSalary; // error here.
*pSalary+=100000; // 如果可以的話多好
const int * pConstInt; // pointer is constant
pConstInt = minSalary; // OK, can point to a constant value
int maxSalary; // this is not a constant value
pConstInt = &maxSalary; // OK too, can be point to a non-constant value.
*pConstInt += 5000; // 哈哈,不要妄想。你不能從這個pointer去改值。
func(const largestruct * pVeryLargeStructure) {
... do something you want here...
... 10000 lines of code below,
... but the sturcture pointed by VeryLargeStructure will not be changed.
}
int * const ptrNotChanged = &minSalary;
ptrNotChanged = &maxSalary; // error here.
State | Definition | 意思是... |
S1 | The S1 sleeping state is a low wake latency sleeping state. In this state, no system context is lost (CPU or chip set) and hardware maintains all system context. | CPU 停止執行,Cache內容已經清掉,但是仍然維持供電,所以CPU的內容仍然都在(register)。 |
S2 | The S2 sleeping state is a low wake latency sleeping state. This state is similar to the S1 sleeping state except that the CPU and system cache context is lost (the OS is responsible for maintaining the caches and CPU context). Control starts from the processor’s reset vector after the wake event. | CPU暫存器以及Cache的內容會丟失,所以當小睡片刻後,再被人叫醒時,OS需要將之前CPU各個暫存器(也就是程式執行到什麼地方)的內容恢復,然後繼續工作。 |
S3 | The S3 sleeping state is a low wake latency sleeping state where all system context is lost except system memory. CPU, cache, and chip set context are lost in this state. Hardware maintains memory context and restores some CPU and L2 configuration context. Control starts from the processor’s reset vector after the wake event. | 這個階段睡的更死了,CPU的內容不但已經不見了,連南北橋的設定值一併都關閉,週邊幾乎除了只剩下記憶體仍舊持續供電外幾乎全數關閉。所以在被叫醒時,BIOS要負責再重新初始化南北橋晶片組,回復CPU睡著前的狀態。這在Windows叫"待命"(Suspend, Suspend to RAM) |
S4 | The S4 sleeping state is the lowest power, longest wake latency sleeping state supported by ACPI. In order to reduce power to a minimum, it is assumed that the hardware platform has powered off all devices. Platform context is maintained. | 這是更進階的睡覺模式,基本上跟關機是一樣的狀態。所以的工作狀態全數關閉。記憶體、週邊全數進入關機模式,但是系統的狀態仍然還需要存在。可是既然所有的電都關閉了,那工作狀態要存在什麼地方?當然是Non Volatile Memory,也就是HDD之類不需要供電仍然能儲存資料的儲存設備。這在Windows裡叫"休眠"(Hibernation or Suspend to Disk)。 |
S5 | The S5 state is similar to the S4 state except that the OS does not save any context. The system is in the “soft” off state and requires a complete boot when it wakes. Software uses a different state value to distinguish between the S5 state and the S4 state to allow for initial boot operations within the BIOS to distinguish whether or not the boot is going to wake from a saved memory image. | 這基本上已經是關機了,因為系統沒有儲存跟工作有關的任何資訊,要再重新工作唯有開機一途。 |