我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用pythoncom.VT_UNKNOWN。
def update_colinfo(not_used, dir_name, fnames): for fname in fnames: full_fname=os.path.join(dir_name,fname) if os.path.isdir(full_fname): print full_fname pidl=shell.SHILCreateFromPath(full_fname,0)[0] pb=shell.SHGetViewStatePropertyBag(pidl, "Shell", shellcon.SHGVSPB_FOLDERNODEFAULTS, pythoncom.IID_IPropertyBag) ## not all folders already have column info, and we're replacing it anyway pb.Write('ColInfo', template_stream) iunk=pb.Read('ColInfo',pythoncom.VT_UNKNOWN) s=iunk.QueryInterface(pythoncom.IID_IStream) s.Write(template_colinfo) s=None ## attribute names read from registry, can't find any way to enumerate IPropertyBag for attr in ('Address','Buttons','Col','Vid','WFlags','FFlags','Sort','SortDir','ShowCmd','FolderType','Mode','Rev'): pb.Write(attr, template_pb.Read(attr)) pb=None
def update_colinfo(not_used, dir_name, fnames): for fname in fnames: full_fname=os.path.join(dir_name,fname) if os.path.isdir(full_fname): print(full_fname) pidl=shell.SHILCreateFromPath(full_fname,0)[0] pb=shell.SHGetViewStatePropertyBag(pidl, "Shell", shellcon.SHGVSPB_FOLDERNODEFAULTS, pythoncom.IID_IPropertyBag) ## not all folders already have column info, and we're replacing it anyway pb.Write('ColInfo', template_stream) iunk=pb.Read('ColInfo',pythoncom.VT_UNKNOWN) s=iunk.QueryInterface(pythoncom.IID_IStream) s.Write(template_colinfo) s=None ## attribute names read from registry, can't find any way to enumerate IPropertyBag for attr in ('Address','Buttons','Col','Vid','WFlags','FFlags','Sort','SortDir','ShowCmd','FolderType','Mode','Rev'): pb.Write(attr, template_pb.Read(attr)) pb=None