線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2434
推到 Plurk!
推到 Facebook!

有人知道SetDisplayConfig 如何用嗎,每次都得到ERROR_INVALID_PARAMETER也不知道怎麼錯,網路上也一堆人在問,可是都沒有答案

尚未結案
chihping
一般會員


發表:3
回覆:6
積分:1
註冊:2009-06-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2010-10-21 13:54:28 IP:114.36.xxx.xxx 訂閱

[code cpp]
char tmp[128];
UINT32 NumPathArrayElements = 0;
UINT32 NumModeInfoArrayElements = 0;
LONG returnValue;
returnValue = GetDisplayConfigBufferSizes(
QDC_ALL_PATHS,
&NumPathArrayElements,
&NumModeInfoArrayElements); // Returns Success
if (returnValue != ERROR_SUCCESS)
{
MessageBox((LPCWSTR)L"Error",(LPCWSTR)L"GetDisplayConfigBufferSizes",0);
return;
}
DISPLAYCONFIG_PATH_INFO *pPathInfoArray =
new DISPLAYCONFIG_PATH_INFO[NumPathArrayElements];

DISPLAYCONFIG_MODE_INFO *pModeInfoArray =
new DISPLAYCONFIG_MODE_INFO[NumModeInfoArrayElements];

returnValue = QueryDisplayConfig(
QDC_ALL_PATHS,
&NumPathArrayElements, pPathInfoArray,
&NumModeInfoArrayElements, pModeInfoArray,
NULL);
if (returnValue != ERROR_SUCCESS)
{
MessageBox((LPCWSTR)L"Error",(LPCWSTR)L"QueryDisplayConfig",0);
return;
}
switch (pModeInfoArray[0].infoType)
{
case DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE:
MessageBox((LPCWSTR)L"INFO_TYPE_SOURCE",(LPCWSTR)L"INFO_TYPE_SOURCE",0);
break;
case DISPLAYCONFIG_MODE_INFO_TYPE_TARGET:
MessageBox((LPCWSTR)L"DISPLAYCONFIG_MODE_INFO_TYPE_TARGET",(LPCWSTR)L"DISPLAYCONFIG_MODE_INFO_TYPE_TARGET",0);
break;
}

//pModeInfoArray[0].sourceMode.width = 800;
//pModeInfoArray[0].sourceMode.height = 600;

//for(int i=0; i //{
// if(pPathInfoArray[i].targetInfo.targetAvailable == 1)
// {
// pPathInfoArray[i].flags = DISPLAYCONFIG_PATH_ACTIVE;
// }
//}
memset(tmp,0x00,sizeof(tmp)),
sprintf(tmp,"%d",NumPathArrayElements);
MessageBox((LPCTSTR)tmp,(LPCWSTR)L"NumPathArrayElements Number",0);
memset(tmp,0x00,sizeof(tmp)),
sprintf(tmp,"%d",NumModeInfoArrayElements);
MessageBox((LPCTSTR)tmp,(LPCWSTR)L"NumModeInfoArrayElements Number",0);
returnValue = SetDisplayConfig(
NumPathArrayElements, pPathInfoArray,
NumModeInfoArrayElements, pModeInfoArray,
SDC_APPLY | SDC_SAVE_TO_DATABASE | SDC_ALLOW_CHANGES);
//| SDC_USE_SUPPLIED_DISPLAY_CONFIG
switch(returnValue)
{
case ERROR_SUCCESS:
MessageBox((LPCWSTR)L"OK",(LPCWSTR)L"SetDisplayConfig",0);
break;
case ERROR_INVALID_PARAMETER:
MessageBox((LPCWSTR)L"ERROR_INVALID_PARAMETER",(LPCWSTR)L"SetDisplayConfig",0);
break;
case ERROR_NOT_SUPPORTED:
MessageBox((LPCWSTR)L"ERROR_NOT_SUPPORTED",(LPCWSTR)L"SetDisplayConfig",0);
break;
case ERROR_ACCESS_DENIED:
MessageBox((LPCWSTR)L"ERROR_ACCESS_DENIED",(LPCWSTR)L"SetDisplayConfig",0);
break;
case ERROR_GEN_FAILURE:
MessageBox((LPCWSTR)L"ERROR_GEN_FAILURE",(LPCWSTR)L"SetDisplayConfig",0);
break;
case ERROR_BAD_CONFIGURATION:
MessageBox((LPCWSTR)L"ERROR_BAD_CONFIGURATION",(LPCWSTR)L"SetDisplayConfig",0);
break;
default:
MessageBox((LPCWSTR)L"UNKNOW",(LPCWSTR)L"SetDisplayConfig",0);
break;
}
delete [] pPathInfoArray;
delete [] pModeInfoArray;
[/code]

系統時間:2017-10-23 4:59:59
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!