|
Hi
I have designed two classes, one called GROUPE which contain two properties and one called GROUPES being a collection of the first one.
I have generated these classes withe the Automatic Class Generator Addin but I obtain an infinite loop between both classes like:
Groupe
-Groupes
--Groupe
---Groupes
----Groupe
--------------------------
Is it correct ?
If not how can I avoid it ?
Thanks
|
|
|
|
|
Classes can and occasionally do have "infinite" loops. It really depends on how you are using them.
my blog
|
|
|
|
|
Hello,
I am making a cleanup wizard that basicly shows the user how to cleanup their computer and then does it for them.
I have run across a problem where i want to delete the temp files, the temp internet files and the history(not as important as it won't free up much space)
I know this is possible because it is done in the windows disk cleanup but i have no idea how to do it. I think it could be done with some API calls but i dont know what they would be.
Can anyone help me out?
|
|
|
|
|
i made program to do that if you want i can send you exe file to do it
|
|
|
|
|
Thanks for the offer but i really need the souce so that i can learn how to do it in the future. Would you mind sending me the code?
Thanks
|
|
|
|
|
what you mean by learn this type of subject not for learn this code for professional if you want the code you can buy it
|
|
|
|
|
What is your problem? It's hard to help when you don't give any info.
If you are using Win9x, the temporary internet files and history folders is located in the windir.
If you are using WinXp, those folders are located in
x:\Documents and Settings\Username\Local Settings\
Where
x is the drive letter and
Username is the name of the user account.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
I am using win XP
I already knwo that the path is:(for me)
C:\Documents and Settings\Owner\Local Settings\
The problem is that i do not know how to delete the files, from the directory as the directory is readonly, and ihave been experimenting with system io, to do the function here is the code i am experimenting with at the moment:
<br />
Imports System.IO <br />
<br />
Public Class Form1 <br />
Inherits System.Windows.Forms.Form <br />
<br />
Dim files() as String = Directory.GetFiles("Your Path\") <br />
<br />
Dim fl as String <br />
<br />
For each fl in Files <br />
File.Delete(fl) <br />
Next<br />
But i am looking for a way to do it with an api call, i am not sure whether this is possible and if so how to do it.
Thnaks
|
|
|
|
|
You won't believe how difficult it really is!
You have to do some COM Interop to clear out the History. You can't just delete the files to do this.
I'll put together a little example when I get home tonight.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
OK... I've got an example working. It's based on the work by goblins in this[^] article here on CodeProject. The code to actually make the call looks something like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim urlHistory As New UrlHistoryClass
Dim obj As IUrlHistoryStg2 = CType(urlHistory, IUrlHistoryStg2)
obj.ClearHistory()
Marshal.ReleaseComObject(obj)
End Sub
You have to make the call TWICE. Once to clear out the History and a second time to clear out the Cached Files History.
The code to make the call HAPPEN looks like this (in C#, I don't have the time to convert it to VB.NET):
using System;
using System.Runtime.InteropServices;
using System.Collections;
namespace Obsolete
{
public enum STATURL_QUERYFLAGS : uint
{
STATURL_QUERYFLAG_ISCACHED = 0x00010000,
STATURL_QUERYFLAG_NOURL = 0x00020000,
STATURL_QUERYFLAG_NOTITLE = 0x00040000,
STATURL_QUERYFLAG_TOPLEVEL = 0x00080000,
}
public enum STATURLFLAGS : uint
{
STATURLFLAG_ISCACHED = 0x00000001,
STATURLFLAG_ISTOPLEVEL = 0x00000002,
}
[StructLayout(LayoutKind.Sequential)]
public struct STATURL
{
public int cbSize;
[MarshalAs(UnmanagedType.LPWStr)] public string pwcsUrl;
[MarshalAs(UnmanagedType.LPWStr)] public string pwcsTitle;
public FILETIME ftLastVisited;
public FILETIME ftLastUpdated;
public FILETIME ftExpires;
public STATURLFLAGS dwFlags;
}
[StructLayout(LayoutKind.Sequential)]
public struct UUID
{
public int Data1;
public short Data2;
public short Data3;
public byte[] Data4;
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("3C374A42-BAE4-11CF-BF7D-00AA006946EE")]
public interface IEnumSTATURL
{
void Next(int celt, ref STATURL rgelt, out int pceltFetched);
void Skip(int celt);
void Reset();
void Clone(out IEnumSTATURL ppenum);
void SetFilter([MarshalAs(UnmanagedType.LPWStr)] string poszFilter, STATURLFLAGS dwFlags);
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("3C374A41-BAE4-11CF-BF7D-00AA006946EE")]
public interface IUrlHistoryStg
{
void AddUrl(string pocsUrl, string pocsTitle, STATURLFLAGS dwFlags);
void DeleteUrl(string pocsUrl, int dwFlags);
void QueryUrl ([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl , int dwFlags , ref STATURL lpSTATURL );
void BindToObject ([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut);
object EnumUrls{[return: MarshalAs(UnmanagedType.IUnknown)] get;}
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("AFA0DC11-C313-11D0-831A-00C04FD5AE38")]
public interface IUrlHistoryStg2 : IUrlHistoryStg
{
new void AddUrl(string pocsUrl, string pocsTitle, STATURLFLAGS dwFlags);
new void DeleteUrl(string pocsUrl, int dwFlags);
new void QueryUrl ([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl , int dwFlags , ref STATURL lpSTATURL );
new void BindToObject ([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut);
new object EnumUrls{[return: MarshalAs(UnmanagedType.IUnknown)] get;}
void AddUrlAndNotify(string pocsUrl, string pocsTitle, int dwFlags, int fWriteHistory, object poctNotify, object punkISFolder);
void ClearHistory();
}
[ComImport]
[Guid("3C374A40-BAE4-11CF-BF7D-00AA006946EE")]
public class UrlHistoryClass
{
}
}
That's alot of work to clear out the History and Temporary Internet Files.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
And Dave Kreskowiak strikes again!
Nice work.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Thankyou Dave,
I have used a C# to vb.net code converter, and afterwards it looked like this:
Imports System<br />
Imports System.Runtime.InteropServices<br />
Imports System.Collections <br />
Namespace Obsolete<br />
Public Enum STATURL_QUERYFLAGS As System.UInt32<br />
STATURL_QUERYFLAG_ISCACHED = 0x00010000<br />
STATURL_QUERYFLAG_NOURL = 0x00020000<br />
STATURL_QUERYFLAG_NOTITLE = 0x00040000<br />
STATURL_QUERYFLAG_TOPLEVEL = 0x00080000<br />
End Enum<br />
Public Enum STATURLFLAGS As System.UInt32<br />
STATURLFLAG_ISCACHED = 0x00000001<br />
STATURLFLAG_ISTOPLEVEL = 0x00000002<br />
End Enum<br />
<br />
'Contains statistics about a URL<br />
<StructLayout(LayoutKind.Sequential)> _ <br />
Public Structure STATURL<br />
Public cbSize As Integer<br />
<MarshalAs(UnmanagedType.LPWStr)) Public String pwcsUrl<br />
<MarshalAs(UnmanagedType.LPWStr)) Public String pwcsTitle<br />
Public ftLastVisited As FILETIME<br />
Public ftLastUpdated As FILETIME<br />
Public ftExpires As FILETIME<br />
Public dwFlags As STATURLFLAGS<br />
End Structure<br />
<br />
<StructLayout(LayoutKind.Sequential)> _ <br />
Public Structure UUID<br />
Public Data1 As Integer<br />
Public Data2 As Short<br />
Public Data3 As Short<br />
Public Data4() As Byte<br />
End Structure<br />
<br />
'Enumerates the cached URLs<br />
<ComImport> _ <br />
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ <br />
<Guid("3C374A42-BAE4-11CF-BF7D-00AA006946EE")> _ <br />
Public Interface IEnumSTATURL<br />
void Next(Integer celt, STATURL rgelt, Integer pceltFetched)<br />
void Skip(Integer celt)<br />
Dim Reset() As void<br />
void Clone( IEnumSTATURL ppEnum) <br />
void Clone( IEnumSTATURL ppenum)<br />
End Enum<br />
void SetFilter((MarshalAs(UnmanagedType.LPWStr)) String poszFilter, STATURLFLAGS dwFlags)<br />
End Interface<br />
<ComImport> _ <br />
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ <br />
<Guid("3C374A41-BAE4-11CF-BF7D-00AA006946EE")> _ <br />
Public Interface IUrlHistoryStg<br />
void AddUrl(String pocsUrl, String pocsTitle, STATURLFLAGS dwFlags)<br />
void DeleteUrl(String pocsUrl, Integer dwFlags)<br />
void QueryUrl ((MarshalAs(UnmanagedType.LPWStr)) String pocsUrl , Integer dwFlags , STATURL lpSTATURL)<br />
void BindToObject ((In) String pocsUrl, (In) UUID riid, IntPtr ppvOut)<br />
Object EnumUrls<br />
{<br />
<Return: MarshalAs(UnmanagedType.IUnknown)) get<br />
<br />
}<br />
End Interface<br />
<br />
<ComImport> _ <br />
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ <br />
(Guid("AFA0DC11-C313-11D0-831A-00C04FD5AE38")> _ <br />
Public Interface IUrlHistoryStg2<br />
Implements IUrlHistoryStg <br />
New void AddUrl(String pocsUrl, String pocsTitle, STATURLFLAGS dwFlags)<br />
New void DeleteUrl(String pocsUrl, Integer dwFlags)<br />
New void QueryUrl ((MarshalAs(UnmanagedType.LPWStr)) String pocsUrl , Integer dwFlags , STATURL lpSTATURL)<br />
New void BindToObject ((In) String pocsUrl, (In) UUID riid, IntPtr ppvOut)<br />
Shadows Property EnumUrls() As Object<br />
End Property<br />
void AddUrlAndNotify(String pocsUrl, String pocsTitle, Integer dwFlags, Integer fWriteHistory, Object poctNotify, Object punkISFolder)<br />
Dim ClearHistory() As void<br />
End Interface<br />
<br />
'UrlHistory class <br />
(ComImport> _ <br />
(Guid("3C374A40-BAE4-11CF-BF7D-00AA006946EE")> _ <br />
Public Class UrlHistoryClass<br />
End Class<br />
End Namespace>
It wasen't very accurate when i compiled it it threw about 13 different errors, i guess the converter couldent convert it completley... I know this is asking a lot but could someone translate it for me? I dont know any C# If not i am sure i can find a way to convert it completely
Thanks.
|
|
|
|
|
I'm experiencing a problem w/ my application written in VB.Net. My application is suppose to open Excel, but when I try to create an object using CreateObject function it throws an exception, Specified cast is not valid.
If I declare the xlApp as Excel.ApplicationClass it works, but a get the same problem, Specified cast is not valid, on the next line, xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook).
I'm using Excel 2000 ver 9.02 and the OS is XP professional.
I decided to load the latest version InteropServices, but I'm not using Office 2002. Even though it's loaded into the system the properties for the Excel COM object is pointing to the old version of Excel 2000.
Any help would be appreciated.
A sample of the code is as follows:
Imports System.Runtime.InteropServices
Imports Excel
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
|
|
|
|
|
I'm assuming you also went into Projects-->Add References-->COM-->Microsoft Excel X.X Object Library (where X.X = your version of Excel).
Also, I have had some odd problems with interops. Unless I used the full domain names, they wouldn't work.
<br />
Dim xlApp As Microsoft.Office.Interop.Excel.Application<br />
Still coaxing software out of the can after all these years...
|
|
|
|
|
Tanstaafl28,
I figured out the problem. There was a conflicted with the PIA files. I just restalled Microsoft Office. Thanks for your time!!!!
lxhan
|
|
|
|
|
How can I rename an NT user using the ADSI(Active Directory Service Interfaces)? The IADs::SetInfo method can only change user's fullname not rename a user.
|
|
|
|
|
You can do it using the System.DirectoryServices namespace:
Imports System.DirectoryServices
.
.
.
' Allocate a new Directory Entry object and point it
' at the user object we want to rename.
Dim de As New DirectoryEntry("LDAP://whateverPathToUserObject")
' Rename the object and commit the changes to the directory.
de.Rename("myNewUsername")
de.CommitChanges()
' Clean up and destroy the Directory Entry object we created.
de.Close()
de.Dispose()
de = Nothing
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks despite I'm not using .NET platform.With its hint,I worked out the solution.
|
|
|
|
|
Is there a way me to use the classes in System.Configuration in a read/write way. I've looked through the examples and documentation ant it seems that it only supports read-only use. I would like to use this functionality in a Options form that would read and save the configurations for my application. Any Ideas? Is there a write-able equivalent to the AppSettingsReader Class?
|
|
|
|
|
Off the top of my head, I would think it dangerous to allow a system namespace to be read/write, but I'm pretty new to this myself.
This does not keep you from creating your own class though.
Still coaxing software out of the can after all these years...
|
|
|
|
|
Yeah, thought so. I am creating a class using xml though. Thanks.
|
|
|
|
|
|
Great article! Though for my purposes I think it would be better if I create my own class to write dynamic properties. I was hoping to add a feature that will allow addition of new configuration sections and additional attributes. Thanks a lot!!
|
|
|
|
|
How do I access a custom section in a custom section group? I was hoping to have something like this:
<br />
<configuration><br />
<configSections><br />
<sectionGroup name="mySectionGroup"><br />
<section name="mySection" type="System.Configuration.NameValueSectionHandler,System" /><br />
</sectionGroup><br />
</configSections><br />
<br />
<mySectionGroup><br />
<mySection setting1="value1" setting2="value2" /><br />
</mySectionGroup><br />
</configuration><br />
|
|
|
|
|
Like what? Make sure you use the < and > buttons at the botrom of the message box when you post here. Anything in < > characters will be treated like HTML tags and not displayed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|