谁能帮我把下面的翻译成VB.net

mynull 2003-08-29 10:25:51
出自:http://groups.google.com/groups?hl=zh-CN&lr=&ie=UTF-8&oe=UTF-8&selm=u8wII1zhCHA.2308%40tkmsftngp12&rnum=4

using System;
using System.Text;
using System.Runtime.InteropServices;

namespace StructuredStorageWrapper
{
public enum SummaryPropId : int
{
Title = 0x00000002,
Subject = 0x00000003,
Author = 0x00000004,
Keywords = 0x00000005,
Comments = 0x00000006,
Template = 0x00000007,
LastSavedBy = 0x00000008,
RevisionNumber = 0x00000009,
TotalEditingTime = 0x0000000A,
LastPrinted = 0x0000000B,
CreateDateTime = 0x0000000C,
LastSaveDateTime = 0x0000000D,
NumPages = 0x0000000E,
NumWords = 0x0000000F,
NumChars = 0x00000010,
Thumbnail = 0x00000011,
AppName = 0x00000012,
Security = 0x00000013
}

public enum STGC : int
{
DEFAULT = 0,
OVERWRITE = 1,
ONLYIFCURRENT = 2,
DANGEROUSLYCOMMITMERELYTODISKCACHE = 4,
CONSOLIDATE = 8
}

public enum PROPSETFLAG : int
{
DEFAULT = 0,
NONSIMPLE = 1,
ANSI = 2,
UNBUFFERED = 4,
CASE_SENSITIVE = 8
}

public enum STGM : int
{
READ = 0x00000000,
WRITE = 0x00000001,
READWRITE = 0x00000002,
SHARE_DENY_NONE = 0x00000040,
SHARE_DENY_READ = 0x00000030,
SHARE_DENY_WRITE = 0x00000020,
SHARE_EXCLUSIVE = 0x00000010,
PRIORITY = 0x00040000,
CREATE = 0x00001000,
CONVERT = 0x00020000,
FAILIFTHERE = 0x00000000,
DIRECT = 0x00000000,
TRANSACTED = 0x00010000,
NOSCRATCH = 0x00100000,
NOSNAPSHOT = 0x00200000,
SIMPLE = 0x08000000,
DIRECT_SWMR = 0x00400000,
DELETEONRELEASE = 0x04000000
}

public enum STGFMT : int
{
STORAGE = 0,
FILE = 3,
ANY = 4,
DOCFILE = 5
}

[StructLayout(LayoutKind.Explicit, Size=8, CharSet=CharSet.Unicode)]
public struct PropSpec
{
[FieldOffset(0)] public int ulKind;
[FieldOffset(4)] public IntPtr Name_Or_ID;
}

[StructLayout(LayoutKind.Explicit, Size=16)]
public struct PropVariant
{
[FieldOffset(0)] public short variantType;
[FieldOffset(8)] public IntPtr pointerValue;
[FieldOffset(8)] public byte byteValue;
[FieldOffset(8)] public long longValue;

public void FromObject(object obj)
{
if (obj.GetType() == typeof(string))
{
this.variantType = (short)VarEnum.VT_LPWSTR;
this.pointerValue = Marshal.StringToHGlobalUni((string)obj);
}
}
}

[ComVisible(true), ComImport(),
Guid("0000013A-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPropertySetStorage
{
uint Create(
[In, MarshalAs(UnmanagedType.Struct)] ref System.Guid rfmtid,
[In] IntPtr pclsid,
[In] int grfFlags,
[In] int grfMode,
ref IPropertyStorage propertyStorage);

int Open(
[In, MarshalAs(UnmanagedType.Struct)] ref System.Guid rfmtid,
[In] int grfMode,
[Out] IPropertyStorage propertyStorage);
}

[ComVisible(true), ComImport(),
Guid("00000138-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPropertyStorage
{
int ReadMultiple(
uint numProperties,
PropSpec[] propertySpecifications,
PropVariant[] propertyValues);

int WriteMultiple(
uint numProperties,
[MarshalAs(UnmanagedType.Struct)] ref PropSpec
propertySpecification,
ref PropVariant propertyValues,
int propIDNameFirst);

uint Commit(
int commitFlags);
}

public enum HResults : uint
{
S_OK = 0,
STG_E_FILEALREADYEXISTS = 0x80030050
}

public class ole32
{
[StructLayout(LayoutKind.Explicit, Size=12,
CharSet=CharSet.Unicode)]
public struct STGOptions
{
[FieldOffset(0)] ushort usVersion;
[FieldOffset(2)] ushort reserved;
[FieldOffset(4)] uint uiSectorSize;
[FieldOffset(8), MarshalAs(UnmanagedType.LPWStr)] string
pwcsTemplateFile;
}

[DllImport("ole32.dll", CharSet=CharSet.Unicode)]
public static extern uint StgCreateStorageEx(
[MarshalAs(UnmanagedType.LPWStr)] string name,
int accessMode, int storageFileFormat, int fileBuffering,
IntPtr options, IntPtr reserved, ref System.Guid riid,
[MarshalAs(UnmanagedType.Interface)] ref IPropertySetStorage
propertySetStorage);

[DllImport("ole32.dll", CharSet=CharSet.Unicode)]
public static extern uint StgOpenStorageEx(
[MarshalAs(UnmanagedType.LPWStr)] string name,
int accessMode, int storageFileFormat, int fileBuffering,
IntPtr options, IntPtr reserved, ref System.Guid riid,
[MarshalAs(UnmanagedType.Interface)] ref IPropertySetStorage
propertySetStorage);
}
}
...全文
61 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
mainone 2003-09-16
  • 打赏
  • 举报
回复
收藏
eshusheng 2003-08-30
  • 打赏
  • 举报
回复
http://www.ragingsmurf.com/vbcsharpconverter.aspx
试试这个。
mynull 2003-08-30
  • 打赏
  • 举报
回复
不行,翻译不了,尤其像 [StructLayout(LayoutKind.Explicit, Size=16)] 这样的属性,和后面的接口,如public interface IPropertySetStorage { uint Create( [In, Mars......
yufenfeila 2003-08-30
  • 打赏
  • 举报
回复
好东西,收藏

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧