Click here to Skip to main content
15,922,015 members
Home / Discussions / C#
   

C#

 
GeneralRe: More Efficient Code Pin
Niklas Ulvinge23-Sep-05 0:42
Niklas Ulvinge23-Sep-05 0:42 
AnswerRe: More Efficient Code -SOLVED Pin
Debs*23-Sep-05 7:11
Debs*23-Sep-05 7:11 
QuestionIEnumIDList.Next(...) is not working :( Pin
daouner22-Sep-05 5:28
daouner22-Sep-05 5:28 
AnswerRe: IEnumIDList.Next(...) is not working :( Pin
Heath Stewart22-Sep-05 6:29
protectorHeath Stewart22-Sep-05 6:29 
GeneralRe: IEnumIDList.Next(...) is not working :( Pin
daouner22-Sep-05 7:25
daouner22-Sep-05 7:25 
GeneralRe: IEnumIDList.Next(...) is not working :( Pin
daouner22-Sep-05 10:00
daouner22-Sep-05 10:00 
GeneralRe: IEnumIDList.Next(...) is not working :( Pin
Heath Stewart22-Sep-05 11:06
protectorHeath Stewart22-Sep-05 11:06 
GeneralRe: IEnumIDList.Next(...) is not working :( Pin
daouner23-Sep-05 7:19
daouner23-Sep-05 7:19 
In my test projects this are the functions that manage the IEnumIDList Interface:
<br />
public static IEnumIDList GetEnumIDList(IntPtr ptrEnumIDList)<br />
		{<br />
			System.Type shellEnumIDListType = System.Type.GetType("JSoftware.CustomTools.ShellLib.IEnumIDList");<br />
			Object obj = Marshal.GetTypedObjectForIUnknown(ptrEnumIDList, shellEnumIDListType);<br />
			IEnumIDList RetVal = (IEnumIDList)obj;<br />
			return RetVal;<br />
		}<br />
<br />
		public static String[] GetSubFolders(IEnumIDList EnumIDList)<br />
		{<br />
			UInt32 celt = 10;<br />
			IntPtr[] ptrList = new IntPtr[celt];<br />
			UInt32 count = 5;<br />
<br />
			String[] PathList;<br />
<br />
			IShellFolder iSubFolder;<br />
			IntPtr ptrRelative = IntPtr.Zero;<br />
			IntPtr ptrSubFolder;<br />
			ShellApi.STRRET ptrData;<br />
<br />
			EnumIDList.Reset();<br />
<br />
			if (EnumIDList.Next(celt, ptrList, out count) == 0)<br />
			{<br />
				PathList = new String[count];<br />
				for (UInt32 i = 0; i < count; i++)<br />
				{<br />
					ShellApi.SHBindToParent(ptrList[i], ShellGUIDs.IID_IShellFolder, out ptrSubFolder, ref ptrRelative);<br />
					iSubFolder = GetShellFolder(ptrSubFolder);<br />
					iSubFolder.GetDisplayNameOf(ptrRelative, (uint)ShellApi.SHGNO.SHGDN_NORMAL, out ptrData);<br />
					ShellApi.StrRetToBSTR(ref ptrData, ptrList[i], out PathList[i]);<br />
				}<br />
				return PathList;<br />
			}<br />
			return null;<br />
		}<br />


The code that uses those functions:

<br />
private void GetMainFolders()<br />
{<br />
DummyTreeNode RootNode;<br />
IntPtr ptrRootFolder;<br />
ShellApi.SHGetFolderLocation(this.Handle, (short)ShellApi.CSIDL.CSIDL_DRIVES, IntPtr.Zero, 0, out ptrRootFolder);<br />
IShellFolder iRootFolder= ShellFunctions.GetShellFolder(ptrRootFolder);<br />
				IntPtr ptrFoldersList;<br />
<br />
				ShellApi.STRRET iInfo;<br />
				iRootFolder.EnumObjects(this.Handle, (Int32)ShellApi.SHCONTF.SHCONTF_FOLDERS | (Int32)ShellApi.SHCONTF.SHCONTF_NONFOLDERS, out ptrFoldersList);<br />
IEnumIDList iFoldersList = ShellFunctions.GetEnumIDList(ptrFoldersList);<br />
RootNode = (DummyTreeNode)Nodes[0];<br />
RootNode.AddSubFolders(iFoldersList);<br />
}<br />
<br />
public void AddSubFolders(IEnumIDList EnumIDList)<br />
		{<br />
			try<br />
			{<br />
				String[] SubFolders = ShellFunctions.GetSubFolders(EnumIDList);<br />
				for (int i = 0; i < SubFolders.Length; i++)<br />
				{<br />
					this.Nodes.Add(new DummyTreeNode(SubFolders[i]));<br />
				}<br />
					<br />
			}<br />
			catch (Exception e)<br />
			{<br />
				System.Windows.Forms.MessageBox.Show(e.Message);<br />
			}<br />
		}<br />
<br />


DummyTreeNode is a class that inherits from TreeNode class. Nodes[0] exists and it is the iRootFolder display name. (These are beta functions and are harder to read... sorry for that)

PS: I get an ExecutionEngineException in GetShellFolder(ptrRootFolder)...
GeneralRe: IEnumIDList.Next(...) is not working :( Pin
Heath Stewart23-Sep-05 7:27
protectorHeath Stewart23-Sep-05 7:27 
GeneralRe: IEnumIDList.Next(...) is not working :( Pin
daouner23-Sep-05 7:34
daouner23-Sep-05 7:34 
GeneralRe: IEnumIDList.Next(...) is not working :( Pin
daouner23-Sep-05 9:08
daouner23-Sep-05 9:08 
QuestionRegular Expression for html tags Pin
brunoconde22-Sep-05 5:15
brunoconde22-Sep-05 5:15 
AnswerRe: Regular Expression for html tags Pin
Guffa22-Sep-05 6:14
Guffa22-Sep-05 6:14 
GeneralRe: Regular Expression for html tags Pin
Anonymous22-Sep-05 8:36
Anonymous22-Sep-05 8:36 
Questionhow to use the AdRotator?? Pin
shanzy22-Sep-05 4:50
shanzy22-Sep-05 4:50 
AnswerRe: how to use the AdRotator?? Pin
shanzy22-Sep-05 5:28
shanzy22-Sep-05 5:28 
AnswerRe: how to use the AdRotator?? Pin
Dave Kreskowiak22-Sep-05 8:12
mveDave Kreskowiak22-Sep-05 8:12 
Questiontrapping hotkey Pin
Sabry190522-Sep-05 4:21
Sabry190522-Sep-05 4:21 
AnswerRe: trapping hotkey Pin
Mridang Agarwalla22-Sep-05 4:36
Mridang Agarwalla22-Sep-05 4:36 
QuestionChange windows system time Pin
djvando22-Sep-05 4:18
djvando22-Sep-05 4:18 
AnswerRe: Change windows system time Pin
Heath Stewart22-Sep-05 6:31
protectorHeath Stewart22-Sep-05 6:31 
QuestionWriting htmlstyle comments in xml Pin
Dan Neely22-Sep-05 3:54
Dan Neely22-Sep-05 3:54 
AnswerRe: Writing htmlstyle comments in xml Pin
Heath Stewart22-Sep-05 6:34
protectorHeath Stewart22-Sep-05 6:34 
GeneralRe: Writing htmlstyle comments in xml Pin
Dan Neely22-Sep-05 7:16
Dan Neely22-Sep-05 7:16 
Questionprogressbar in a statusbar panel Pin
Mridang Agarwalla22-Sep-05 3:43
Mridang Agarwalla22-Sep-05 3:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.