面對華麗的Windows案頭,工作的心情或許好很多,但是久了總會失去興趣,總想定期地更新案頭的圖片。軟體開發人員又面對這樣的需求了,需要怎麼樣去做呢?努力去找API函數吧。到目前為止,還有很多變案頭圖片的軟體,並且還能很掙錢的。其實設定案頭圖片的需求,在目前數位相片處理軟體也有現實的需求,比如當你去旅遊回來後,想把照片當作案頭圖片,就可以在處理圖片時就設定為案頭圖片。這樣就需要使用函數SystemParametersInfo來完成這項工作了,當然這個函數還有很多其它功能,比如擷取案頭工作區的大小。 函數SystemParametersInfo聲明如下:WINUSERAPIBOOLWINAPISystemParametersInfoA( __in UINT uiAction, __in UINT uiParam, __inout_opt PVOID pvParam, __in UINT fWinIni);WINUSERAPIBOOLWINAPISystemParametersInfoW( __in UINT uiAction, __in UINT uiParam, __inout_opt PVOID pvParam, __in UINT fWinIni);#ifdef UNICODE#define SystemParametersInfo SystemParametersInfoW#else#define SystemParametersInfo SystemParametersInfoA#endif // !UNICODE
uiAction是作不同的巨集指令引數。
uiParam是設定的參數。
pvParam是設定或返回的參數。
fWinIni是設定的參數。 調用函數的例子如下:#001 //#002 //擷取系統配置資訊。#003 //蔡軍生 2007/11/16 QQ:9073204 深圳#004 void GetSystemParam(void)#005 {#006 //擷取案頭牆紙的路徑。#007 //SPI_GETDESKWALLPAPER#008 TCHAR chPath[MAX_PATH];
#009 if (SystemParametersInfo(SPI_GETDESKWALLPAPER,MAX_PATH,chPath,0))#010 {#011 //#012 OutputDebugString(chPath);#013 OutputDebugString(_T(""r"n"));#014 }#015 #016 //擷取工作區的大小。#017 //SPI_GETWORKAREA#018 RECT rcWorkArea;
#019 if (SystemParametersInfo(SPI_GETWORKAREA,0,&rcWorkArea,0))#020 {#021 //#022 const int nBufSize = 256;#023 TCHAR chBuf[nBufSize];#024 #025 wsprintf(chBuf,_T("%u,%u,%u,%u"),rcWorkArea.left,rcWorkArea.top,#026 rcWorkArea.right,rcWorkArea.bottom);#027 #028 OutputDebugString(chBuf);#029 OutputDebugString(_T(""r"n"));#030 }#031
#032 }
delphi 代碼
var rcWorkArea: TRect;
begin
SystemParametersInfo(SPI_GETWORKAREA,0, Pointer(@rcWorkArea), 0);
szTmp1 := Format( 'Left: %d top: %d Right: %d bottom: %d ',
[rcWorkArea.Left, rcWorkArea.Top, rcWorkArea.Right, rcWorkArea.Bottom]);
Caption := szTmp1;
end;