本文整理汇总了C#中System.Runtime.InteropServices.ComTypes类的典型用法代码示例。如果您正苦于以下问题:C# ComTypes类的具体用法?C# ComTypes怎么用?C# ComTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComTypes类属于System.Runtime.InteropServices命名空间,在下文中一共展示了ComTypes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ComTypeEnumDesc
internal ComTypeEnumDesc(ComTypes.ITypeInfo typeInfo, ComTypeLibDesc typeLibDesc) :
base(typeInfo, ComType.Enum, typeLibDesc) {
ComTypes.TYPEATTR typeAttr = ComRuntimeHelpers.GetTypeAttrForTypeInfo(typeInfo);
string[] memberNames = new string[typeAttr.cVars];
object[] memberValues = new object[typeAttr.cVars];
IntPtr p = IntPtr.Zero;
// For each enum member get name and value.
for (int i = 0; i < typeAttr.cVars; i++) {
typeInfo.GetVarDesc(i, out p);
// Get the enum member value (as object).
ComTypes.VARDESC varDesc;
try {
varDesc = (ComTypes.VARDESC)Marshal.PtrToStructure(p, typeof(ComTypes.VARDESC));
if (varDesc.varkind == ComTypes.VARKIND.VAR_CONST) {
memberValues[i] = Marshal.GetObjectForNativeVariant(varDesc.desc.lpvarValue);
}
} finally {
typeInfo.ReleaseVarDesc(p);
}
// Get the enum member name
memberNames[i] = ComRuntimeHelpers.GetNameOfMethod(typeInfo, varDesc.memid);
}
_memberNames = memberNames;
_memberValues = memberValues;
}
开发者ID:bclubb,项目名称:ironruby,代码行数:32,代码来源:ComTypeEnumDesc.cs
示例2: GetNameOfType
internal static string GetNameOfType(ComTypes.ITypeInfo typeInfo) {
string name;
string documentation;
GetInfoFromType(typeInfo, out name, out documentation);
return name;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:7,代码来源:ComRuntimeHelpers.cs
示例3: GetNameOfLib
internal static string GetNameOfLib(ComTypes.ITypeLib typeLib) {
string name;
string strDocString;
int dwHelpContext;
string strHelpFile;
typeLib.GetDocumentation(-1, out name, out strDocString, out dwHelpContext, out strHelpFile);
return name;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:9,代码来源:ComRuntimeHelpers.cs
示例4: GetFromTypeLib
internal static ComTypeLibDesc GetFromTypeLib(ComTypes.ITypeLib typeLib) {
// check whether we have already loaded this type library
ComTypes.TYPELIBATTR typeLibAttr = ComRuntimeHelpers.GetTypeAttrForTypeLib(typeLib);
ComTypeLibDesc typeLibDesc;
lock (_CachedTypeLibDesc) {
if (_CachedTypeLibDesc.TryGetValue(typeLibAttr.guid, out typeLibDesc)) {
return typeLibDesc;
}
}
typeLibDesc = new ComTypeLibDesc();
typeLibDesc._typeLibName = ComRuntimeHelpers.GetNameOfLib(typeLib);
int countTypes = typeLib.GetTypeInfoCount();
for (int i = 0; i < countTypes; i++) {
ComTypes.TYPEKIND typeKind;
typeLib.GetTypeInfoType(i, out typeKind);
ComTypes.ITypeInfo typeInfo;
if (typeKind == ComTypes.TYPEKIND.TKIND_COCLASS) {
typeLib.GetTypeInfo(i, out typeInfo);
ComTypeClassDesc classDesc = new ComTypeClassDesc(typeInfo);
typeLibDesc._classes.AddLast(classDesc);
} else if (typeKind == ComTypes.TYPEKIND.TKIND_ENUM) {
typeLib.GetTypeInfo(i, out typeInfo);
ComTypeEnumDesc enumDesc = new ComTypeEnumDesc(typeInfo);
typeLibDesc._enums.Add(enumDesc.TypeName, enumDesc);
}
}
// cache the typelib using the guid as the dictionary key
lock (_CachedTypeLibDesc) {
//check if we are late and somebody already added the key.
ComTypeLibDesc curLibDesc;
if (_CachedTypeLibDesc.TryGetValue(typeLibAttr.guid, out curLibDesc)) {
return curLibDesc;
}
_CachedTypeLibDesc.Add(typeLibAttr.guid, typeLibDesc);
}
return typeLibDesc;
}
开发者ID:tnachen,项目名称:ironruby,代码行数:44,代码来源:ComTypeLibDesc.cs
示例5: SetFileTimeProxy
public int SetFileTimeProxy(
IntPtr rawFileName,
ref ComTypes.FILETIME rawCreationTime,
ref ComTypes.FILETIME rawLastAccessTime,
ref ComTypes.FILETIME rawLastWriteTime,
ref DOKAN_FILE_INFO rawFileInfo)
{
try
{
string file = GetFileName(rawFileName);
long time;
time = ((long)rawCreationTime.dwHighDateTime << 32) + (uint)rawCreationTime.dwLowDateTime;
DateTime ctime = DateTime.FromFileTime(time);
if (time == 0)
ctime = DateTime.MinValue;
time = ((long)rawLastAccessTime.dwHighDateTime << 32) + (uint)rawLastAccessTime.dwLowDateTime;
DateTime atime = DateTime.FromFileTime(time);
if (time == 0)
atime = DateTime.MinValue;
time = ((long)rawLastWriteTime.dwHighDateTime << 32) + (uint)rawLastWriteTime.dwLowDateTime;
DateTime mtime = DateTime.FromFileTime(time);
if (time == 0)
mtime = DateTime.MinValue;
return operations_.SetFileTime(
file, ctime, atime, mtime, GetFileInfo(ref rawFileInfo));
}
catch (Exception e)
{
Console.Error.WriteLine(e.ToString());
return -1;
}
}
开发者ID:cristhiand3,项目名称:mssqlfs,代码行数:41,代码来源:Proxy.cs
示例6: GetInfoFromType
internal static void GetInfoFromType(ComTypes.ITypeInfo typeInfo, out string name, out string documentation) {
int dwHelpContext;
string strHelpFile;
typeInfo.GetDocumentation(-1, out name, out documentation, out dwHelpContext, out strHelpFile);
}
开发者ID:andreakn,项目名称:ironruby,代码行数:6,代码来源:ComRuntimeHelpers.cs
示例7: GetTypeAttrForTypeLib
internal static ComTypes.TYPELIBATTR GetTypeAttrForTypeLib(ComTypes.ITypeLib typeLib) {
IntPtr pAttrs = IntPtr.Zero;
typeLib.GetLibAttr(out pAttrs);
// GetTypeAttr should never return null, this is just to be safe
if (pAttrs == IntPtr.Zero) {
throw Error.CannotRetrieveTypeInformation();
}
try {
return (ComTypes.TYPELIBATTR)Marshal.PtrToStructure(pAttrs, typeof(ComTypes.TYPELIBATTR));
} finally {
typeLib.ReleaseTLibAttr(pAttrs);
}
}
开发者ID:andreakn,项目名称:ironruby,代码行数:15,代码来源:ComRuntimeHelpers.cs
示例8: GetNameOfMethod
internal static string GetNameOfMethod(ComTypes.ITypeInfo typeInfo, int memid) {
int cNames;
string[] rgNames = new string[1];
typeInfo.GetNames(memid, rgNames, 1, out cNames);
return rgNames[0];
}
开发者ID:andreakn,项目名称:ironruby,代码行数:6,代码来源:ComRuntimeHelpers.cs
示例9: IDispatchInvoke
public static int IDispatchInvoke(
IntPtr dispatchPointer,
int memberDispId,
ComTypes.INVOKEKIND flags,
ref ComTypes.DISPPARAMS dispParams,
out Variant result,
out ExcepInfo excepInfo,
out uint argErr
) {
int hresult = _IDispatchInvoke(
dispatchPointer,
memberDispId,
flags,
ref dispParams,
out result,
out excepInfo,
out argErr
);
if (hresult == ComHresults.DISP_E_MEMBERNOTFOUND
&& (flags & ComTypes.INVOKEKIND.INVOKE_FUNC) != 0
&& (flags & (ComTypes.INVOKEKIND.INVOKE_PROPERTYPUT | ComTypes.INVOKEKIND.INVOKE_PROPERTYPUTREF)) == 0) {
// Re-invoke with no result argument to accomodate Word
hresult = _IDispatchInvokeNoResult(
dispatchPointer,
memberDispId,
ComTypes.INVOKEKIND.INVOKE_FUNC,
ref dispParams,
out result,
out excepInfo,
out argErr);
}
return hresult;
}
开发者ID:andreakn,项目名称:ironruby,代码行数:36,代码来源:ComRuntimeHelpers.cs
示例10: GetFuncDescForDescIndex
private static void GetFuncDescForDescIndex(ComTypes.ITypeInfo typeInfo, int funcIndex, out ComTypes.FUNCDESC funcDesc, out IntPtr funcDescHandle) {
IntPtr pFuncDesc = IntPtr.Zero;
typeInfo.GetFuncDesc(funcIndex, out pFuncDesc);
// GetFuncDesc should never return null, this is just to be safe
if (pFuncDesc == IntPtr.Zero) {
throw Error.CannotRetrieveTypeInformation();
}
funcDesc = (ComTypes.FUNCDESC)Marshal.PtrToStructure(pFuncDesc, typeof(ComTypes.FUNCDESC));
funcDescHandle = pFuncDesc;
}
开发者ID:sbc100,项目名称:mono,代码行数:12,代码来源:IDispatchComObject.cs
示例11: ScanSourceInterface
private static void ScanSourceInterface(ComTypes.ITypeInfo sourceTypeInfo, ref Dictionary<string, ComEventDesc> events) {
ComTypes.TYPEATTR sourceTypeAttribute = ComRuntimeHelpers.GetTypeAttrForTypeInfo(sourceTypeInfo);
for (int index = 0; index < sourceTypeAttribute.cFuncs; index++) {
IntPtr funcDescHandleToRelease = IntPtr.Zero;
try {
ComTypes.FUNCDESC funcDesc;
GetFuncDescForDescIndex(sourceTypeInfo, index, out funcDesc, out funcDescHandleToRelease);
// we are not interested in hidden or restricted functions for now.
if ((funcDesc.wFuncFlags & (int)ComTypes.FUNCFLAGS.FUNCFLAG_FHIDDEN) != 0) {
continue;
}
if ((funcDesc.wFuncFlags & (int)ComTypes.FUNCFLAGS.FUNCFLAG_FRESTRICTED) != 0) {
continue;
}
string name = ComRuntimeHelpers.GetNameOfMethod(sourceTypeInfo, funcDesc.memid);
name = name.ToUpper(System.Globalization.CultureInfo.InvariantCulture);
// Sometimes coclass has multiple source interfaces. Usually this is caused by
// adding new events and putting them on new interfaces while keeping the
// old interfaces around. This may cause name collisioning which we are
// resolving by keeping only the first event with the same name.
if (events.ContainsKey(name) == false) {
ComEventDesc eventDesc = new ComEventDesc();
eventDesc.dispid = funcDesc.memid;
eventDesc.sourceIID = sourceTypeAttribute.guid;
events.Add(name, eventDesc);
}
} finally {
if (funcDescHandleToRelease != IntPtr.Zero) {
sourceTypeInfo.ReleaseFuncDesc(funcDescHandleToRelease);
}
}
}
}
开发者ID:sbc100,项目名称:mono,代码行数:38,代码来源:IDispatchComObject.cs
示例12: GetFromTypeLib
internal static ComTypeLibDesc GetFromTypeLib(ComTypes.ITypeLib typeLib) {
// check whether we have already loaded this type library
ComTypes.TYPELIBATTR typeLibAttr = ComRuntimeHelpers.GetTypeAttrForTypeLib(typeLib);
ComTypeLibDesc typeLibDesc;
lock (_CachedTypeLibDesc) {
if (_CachedTypeLibDesc.TryGetValue(typeLibAttr.guid, out typeLibDesc)) {
return typeLibDesc;
}
}
typeLibDesc = new ComTypeLibDesc();
typeLibDesc._typeLibName = ComRuntimeHelpers.GetNameOfLib(typeLib);
typeLibDesc._typeLibAttributes = typeLibAttr;
int countTypes = typeLib.GetTypeInfoCount();
for (int i = 0; i < countTypes; i++) {
ComTypes.TYPEKIND typeKind;
typeLib.GetTypeInfoType(i, out typeKind);
ComTypes.ITypeInfo typeInfo;
typeLib.GetTypeInfo(i, out typeInfo);
if (typeKind == ComTypes.TYPEKIND.TKIND_COCLASS) {
ComTypeClassDesc classDesc = new ComTypeClassDesc(typeInfo, typeLibDesc);
typeLibDesc._classes.AddLast(classDesc);
} else if (typeKind == ComTypes.TYPEKIND.TKIND_ENUM) {
ComTypeEnumDesc enumDesc = new ComTypeEnumDesc(typeInfo, typeLibDesc);
typeLibDesc._enums.Add(enumDesc.TypeName, enumDesc);
}
else if (typeKind == ComTypes.TYPEKIND.TKIND_ALIAS) {
ComTypes.TYPEATTR typeAttr = ComRuntimeHelpers.GetTypeAttrForTypeInfo(typeInfo);
if (typeAttr.tdescAlias.vt == (short)VarEnum.VT_USERDEFINED) {
string aliasName, documentation;
ComRuntimeHelpers.GetInfoFromType(typeInfo, out aliasName, out documentation);
ComTypes.ITypeInfo referencedTypeInfo;
typeInfo.GetRefTypeInfo(typeAttr.tdescAlias.lpValue.ToInt32(), out referencedTypeInfo);
ComTypes.TYPEATTR referencedTypeAttr = ComRuntimeHelpers.GetTypeAttrForTypeInfo(referencedTypeInfo);
ComTypes.TYPEKIND referencedTypeKind = referencedTypeAttr.typekind;
if (referencedTypeKind == ComTypes.TYPEKIND.TKIND_ENUM) {
ComTypeEnumDesc enumDesc = new ComTypeEnumDesc(referencedTypeInfo, typeLibDesc);
typeLibDesc._enums.Add(aliasName, enumDesc);
}
}
}
}
// cached the typelib using the guid as the dictionary key
lock (_CachedTypeLibDesc) {
_CachedTypeLibDesc.Add(typeLibAttr.guid, typeLibDesc);
}
return typeLibDesc;
}
开发者ID:aceptra,项目名称:ironruby,代码行数:56,代码来源:ComTypeLibDesc.cs
示例13: GetCoClassTypeInfo
private static ComTypes.ITypeInfo GetCoClassTypeInfo(object rcw, ComTypes.ITypeInfo typeInfo) {
Debug.Assert(typeInfo != null);
IProvideClassInfo provideClassInfo = rcw as IProvideClassInfo;
if (provideClassInfo != null) {
IntPtr typeInfoPtr = IntPtr.Zero;
try {
provideClassInfo.GetClassInfo(out typeInfoPtr);
if (typeInfoPtr != IntPtr.Zero) {
return Marshal.GetObjectForIUnknown(typeInfoPtr) as ComTypes.ITypeInfo;
}
} finally {
if (typeInfoPtr != IntPtr.Zero) {
Marshal.Release(typeInfoPtr);
}
}
}
// retrieving class information through IPCI has failed -
// we can try scanning the typelib to find the coclass
ComTypes.ITypeLib typeLib;
int typeInfoIndex;
typeInfo.GetContainingTypeLib(out typeLib, out typeInfoIndex);
string typeName = ComRuntimeHelpers.GetNameOfType(typeInfo);
ComTypeLibDesc typeLibDesc = ComTypeLibDesc.GetFromTypeLib(typeLib);
ComTypeClassDesc coclassDesc = typeLibDesc.GetCoClassForInterface(typeName);
if (coclassDesc == null) {
return null;
}
ComTypes.ITypeInfo typeInfoCoClass;
Guid coclassGuid = coclassDesc.Guid;
typeLib.GetTypeInfoOfGuid(ref coclassGuid, out typeInfoCoClass);
return typeInfoCoClass;
}
开发者ID:sbc100,项目名称:mono,代码行数:37,代码来源:IDispatchComObject.cs
示例14: ComMethodInformation
internal ComMethodInformation(bool hasvarargs, bool hasoptional, ParameterInformation[] arguments, Type returnType, int dispId, COM.INVOKEKIND invokekind)
: base(hasvarargs, hasoptional, arguments)
{
this.ReturnType = returnType;
this.DispId = dispId;
this.InvokeKind = invokekind;
}
开发者ID:40a,项目名称:PowerShell,代码行数:7,代码来源:ComMethod.cs
示例15: ComTypeInfo
/// <summary>
/// Constructor
/// </summary>
/// <param name="info">ITypeInfo object being wrapped by this object</param>
internal ComTypeInfo(COM.ITypeInfo info)
{
_typeinfo = info;
_properties = new Dictionary<String, ComProperty>(StringComparer.OrdinalIgnoreCase);
_methods = new Dictionary<String, ComMethod>(StringComparer.OrdinalIgnoreCase);
if (_typeinfo != null)
{
Initialize();
}
}
开发者ID:40a,项目名称:PowerShell,代码行数:15,代码来源:ComTypeInfo.cs
示例16: FiletimeToDateTime
private DateTime FiletimeToDateTime(ComType.FILETIME FileTime)
{
try
{
if (FileTime.dwLowDateTime < 0) FileTime.dwLowDateTime = 0;
if (FileTime.dwHighDateTime < 0) FileTime.dwHighDateTime = 0;
long RawFileTime = (((long)FileTime.dwHighDateTime) << 32) + FileTime.dwLowDateTime;
return DateTime.FromFileTimeUtc(RawFileTime);
}
catch { return new DateTime(); }
}
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:12,代码来源:DateTypes.cs
示例17: Stat
public void Stat(out COMTypes.STATSTG pstatstg, int grfStatFlag)
{
pstatstg = new COMTypes.STATSTG();
pstatstg.cbSize = this.stm.Length;
}
开发者ID:redshiftrobotics,项目名称:telemetry_Archive,代码行数:5,代码来源:WIN32.cs
示例18: Clone
//----------------------------------
// IStream
//----------------------------------
public void Clone(out COMTypes.IStream ppstm)
{
throw new NotImplementedException();
}
开发者ID:redshiftrobotics,项目名称:telemetry_Archive,代码行数:7,代码来源:WIN32.cs
示例19: GetTypeFromTypeDesc
/// <summary>
/// Determine .net type for the given type descriptor
/// </summary>
/// <param name="typedesc">COM type descriptor to convert</param>
/// <returns>type represented by the typedesc</returns>
internal static Type GetTypeFromTypeDesc(COM.TYPEDESC typedesc)
{
VarEnum vt = (VarEnum)typedesc.vt;
return VarEnumSelector.GetTypeForVarEnum(vt);
}
开发者ID:40a,项目名称:PowerShell,代码行数:10,代码来源:ComUtil.cs
示例20: GetStringFromTypeDesc
// Disable obsolete warning about VarEnum in CoreCLR
#pragma warning disable 618
/// <summary>
/// This function gets a string representation of the Type Descriptor
/// This is used in generating signature for Properties and Methods.
/// </summary>
/// <param name="typeinfo">Reference to the type info to which the type descriptor belongs</param>
/// <param name="typedesc">reference to type descriptor which is being converted to string from</param>
/// <returns>string representation of the type descriptor</returns>
private static string GetStringFromTypeDesc(COM.ITypeInfo typeinfo, COM.TYPEDESC typedesc)
{
if ((VarEnum)typedesc.vt == VarEnum.VT_PTR)
{
COM.TYPEDESC refdesc = ClrFacade.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
return GetStringFromTypeDesc(typeinfo, refdesc);
}
if ((VarEnum)typedesc.vt == VarEnum.VT_SAFEARRAY)
{
COM.TYPEDESC refdesc = ClrFacade.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
return "SAFEARRAY(" + GetStringFromTypeDesc(typeinfo, refdesc) + ")";
}
if ((VarEnum)typedesc.vt == VarEnum.VT_USERDEFINED)
{
return GetStringFromCustomType(typeinfo, typedesc.lpValue);
}
switch ((VarEnum)typedesc.vt)
{
case VarEnum.VT_I1:
return "char";
case VarEnum.VT_I2:
return "short";
case VarEnum.VT_I4:
case VarEnum.VT_INT:
case VarEnum.VT_HRESULT:
return "int";
case VarEnum.VT_I8:
return "int64";
case VarEnum.VT_R4:
return "float";
case VarEnum.VT_R8:
return "double";
case VarEnum.VT_UI1:
return "byte";
case VarEnum.VT_UI2:
return "ushort";
case VarEnum.VT_UI4:
case VarEnum.VT_UINT:
return "uint";
case VarEnum.VT_UI8:
return "uint64";
case VarEnum.VT_BSTR:
case VarEnum.VT_LPSTR:
case VarEnum.VT_LPWSTR:
return "string";
case VarEnum.VT_DATE:
return "Date";
case VarEnum.VT_BOOL:
return "bool";
case VarEnum.VT_CY:
return "currency";
case VarEnum.VT_DECIMAL:
return "decimal";
case VarEnum.VT_CLSID:
return "clsid";
case VarEnum.VT_DISPATCH:
return "IDispatch";
case VarEnum.VT_UNKNOWN:
return "IUnknown";
case VarEnum.VT_VARIANT:
return "Variant";
case VarEnum.VT_VOID:
return "void";
case VarEnum.VT_ARRAY:
return "object[]";
case VarEnum.VT_EMPTY:
//.........这里部分代码省略.........
开发者ID:40a,项目名称:PowerShell,代码行数:101,代码来源:ComUtil.cs
注:本文中的System.Runtime.InteropServices.ComTypes类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论