我是這個新手。我試圖將propvariant轉換爲C#中的變體#支持變體C#
我有這樣的代碼。
public static object PropValueToVariant(PROPVARIANT Value)
{
object result;
DateTime stTime;
DateTime ftTime;
object __Null;
// Convert the prop variant to variant data type
switch(Value.vt)
{
//@ Undeclared identifier(3): 'VT_I1'
case VT_I1:
//@ Unsupported property or method(C): 'bVal'
result = Value.bVal;
break;
//@ Undeclared identifier(3): 'VT_UI1'
case VT_UI1:
//@ Unsupported property or method(C): 'bVal'
result = Value.bVal;
break;
//@ Undeclared identifier(3): 'VT_I2'
case VT_I2:
//@ Unsupported property or method(C): 'iVal'
result = Value.iVal;
break;
//@ Undeclared identifier(3): 'VT_UI2'
case VT_UI2:
//@ Unsupported property or method(C): 'uiVal'
result = Value.uiVal;
break;
//@ Undeclared identifier(3): 'VT_I4'
case VT_I4:
//@ Unsupported property or method(C): 'lVal'
result = Value.lVal;
break;
//@ Undeclared identifier(3): 'VT_UI4'
case VT_UI4:
//@ Unsupported property or method(C): 'ulVal'
result = ((int)Value.ulVal);
break;
//@ Undeclared identifier(3): 'VT_I8'
case VT_I8:
//@ Unsupported property or method(C): 'hVal'
//@ Unsupported property or method(D): 'LowPart'
result = ((int)Value.hVal.LowPart);
break;
//@ Undeclared identifier(3): 'VT_UI8'
case VT_UI8:
//@ Unsupported property or method(C): 'uhVal'
//@ Unsupported property or method(D): 'LowPart'
result = ((int)Value.uhVal.LowPart);
break;
//@ Undeclared identifier(3): 'VT_BOOL'
case VT_BOOL:
//@ Unsupported property or method(C): 'boolVal'
result = Value.boolVal;
break;
//@ Undeclared identifier(3): 'VT_R4'
case VT_R4:
//@ Unsupported property or method(C): 'fltVal'
result = Value.fltVal;
break;
//@ Undeclared identifier(3): 'VT_R8'
case VT_R8:
//@ Unsupported property or method(C): 'dblVal'
result = Value.dblVal;
break;
//@ Undeclared identifier(3): 'VT_CY'
case VT_CY:
//@ Unsupported property or method(C): 'cyVal'
result = Value.cyVal;
break;
//@ Undeclared identifier(3): 'VT_ERROR'
case VT_ERROR:
//@ Unsupported property or method(C): 'scode'
result = Value.scode;
break;
//@ Undeclared identifier(3): 'VT_DATE'
case VT_DATE:
//@ Unsupported property or method(C): 'date'
result = Value.date;
break;
//@ Undeclared identifier(3): 'VT_FILETIME'
case VT_FILETIME:
//@ Unsupported property or method(C): 'filetime'
//@ Unsupported function or procedure: 'FileTimeToLocalFileTime'
FileTimeToLocalFileTime(Value.filetime, ftTime);
//@ Undeclared identifier(3): 'FileTimeToSystemTime'
FileTimeToSystemTime(ftTime, stTime);
result = stTime;
break;
//@ Undeclared identifier(3): 'VT_CLSID'
case VT_CLSID:
//@ Unsupported property or method(C): 'puuid'
result = Value.puuid.ToString();
break;
//@ Undeclared identifier(3): 'VT_BSTR'
case VT_BSTR:
//@ Unsupported property or method(C): 'bstrVal'
result = Value.bstrVal;
break;
//@ Undeclared identifier(3): 'VT_LPSTR'
case VT_LPSTR:
//@ Unsupported property or method(C): 'pszVal'
result = (Value.pszVal as string);
break;
//@ Undeclared identifier(3): 'VT_LPWSTR'
case VT_LPWSTR:
result = WideCharToString(Value.pwszVal);
break;
default:
result = __Null;
break;
}
return result;
}
爲什麼我得到案例名稱的錯誤?同時它不明白ulval,lval中,等....
非常感謝你的幫助
這聽起來像「這是幹什麼?」。在問這裏之前,先查看如何使用目標語言。 – Azulflame
我正致力於將delphi代碼轉換爲C#,並自動將工具轉換爲此工具。我從來沒有在C#之前工作過 –
「案例名稱錯誤」,你究竟是什麼意思? – user287107