|
|
I am wondering what is the best way to store data like email accounts and what not for a email program(checks if you ahve new mail).
Thanks!
|
|
|
|
|
it really depends on what exactly your doing with your data. if you are going to be doing a bunch of lookups, then consider a Hashtable, but remember for efficiency to implement your own HashProvider and Comparer.
see Hashtable in MSDN for more information
Soliant | email
"The 'B' in Visual Basic means Beginner" - R. Bischoff
|
|
|
|
|
I am posting this here in case anyone has an idea or can help...
Ok, I understand that the NetServerEnum API (netapi.dll) functions do not work on a Win9x machine. In VB6, I had code to enumerate Servers on a Windows9x machine, however, porting it to VB.NET seems impossible. I have it working...somewhat. However, it only enumerates the Top-Level Node everytime!
If someone could please shed some light on what I am doing wrong I would greatly appreciate it! This was all guess-work on my part even though I understand Marshalling a little bit.
Here's what I have so far:
'Declarations
'API Declarations
Private Declare Auto Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Integer, ByVal dwBytes As Integer) As Integer
Private Declare Auto Function GlobalFree Lib "kernel32" (ByVal hMem As Integer) As Integer
'API Declarations for Win9x
Private Declare Ansi Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" (ByVal dwScope As Integer, ByVal dwType As Integer, ByVal dwUsage As Integer, ByRef lpNetResource As IntPtr, ByRef lphEnum As Integer) As Integer
Private Declare Ansi Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" (ByVal hEnum As Integer, ByRef lpcCount As Integer, ByVal lpBuffer As Integer, ByRef lpBufferSize As Integer) As Integer
Private Declare Ansi Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Integer) As Integer
'Structures
<Runtime.InteropServices.StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Private Structure NETRESOURCE
Dim Scope As Integer
Dim Type As Integer
Dim DisplayType As Integer
Dim Usage As Integer
Dim LocalName As IntPtr
Dim RemoteName As IntPtr
Dim Comment As IntPtr
Dim Provider As IntPtr
End Structure
'Constants for WNetEnum
Private Enum ResourceScopes
resConnected = &H1 'All currently connected resources (the dwUsage parameter is ignored)
resGlobalNet = &H2 'All resources on the network.
resRemembered = &H3 'All remembered (persistent) connections (dwUsage is ignored)
resRecent = &H4
resContext = &H5
End Enum
Private Enum ResourceTypes
resAny = &H0 'All resources (this value cannot be combined with RESOURCETYPE_DISK or RESOURCETYPE_PRINT).
resDisk = &H1 'All disk resources.
resPrinter = &H2 'All print resources.
resReserved = &H8
resUnknown = &HFFFF
End Enum
Private Enum ResourceUseages 'Ignored if the ResourceScope is not 'resGlobalNet'
resAll = ((&H1) Or (&H2))
resConnectable = &H1
resContainer = &H2
resNoLocalDevice = &H4
resSibling = &H8
resReserved = &H80000000
End Enum
Private Enum ResourceDisplayTypes 'Used to Determine the Resource Type of the NETRESOURCE Struct
resGeneric = &H0
resDomain = &H1
resServer = &H2
resShare = &H3
resFile = &H4
resGroup = &H5
resNetwork = &H6
resRoot = &H7
resShareAdmin = &H8
resDirectory = &H9
resTree = &HA
End Enum
'Enumerations
Public Enum ServerTypes
All = &HFFFFFFFF '/* handy for NetServerEnum2 */
Browsers = &H10000
Browser_Backup = &H20000
Browser_Master = &H40000
Domains = &H80000000
DomainController = &H8
DomainBackController = &H10
DomainMaster = &H80000
DomainMember = &H100
Novell = &H80
NTClusters = &H1000000 '/* NT Cluster */
Servers = &H2 ' All Servers
ServersDialIn = &H400
ServersLocal = &H40000000
ServersPrintQ = &H200
ServersNT = &H8000
ServersSQL = &H4 ' SQL Server
ServersXenix = &H800
ServersUnix = &H800
TimeServers = &H20
Workstations = &H1
WorkstationsNT = &H1000
WorkstationsWin9x = &H400000 '/* Windows95 and above */
End Enum
'Routine to Refresh Servers on a Win9x Machine (uses Recursion)
Private Sub RefreshServersWin9x(Optional ByVal Domain As String = Nothing)
Dim vResource As NETRESOURCE
Dim hResult, hEnum, hBuffer, hPointer, i As Integer
Dim nBufferSize As Integer = 16384, nCount As Integer = &HFFFFFFFF
Const GMEM_FIXED As Integer = &H0
Const GMEM_ZEROINIT As Integer = &H40
Const GPTR As Integer = (GMEM_FIXED Or GMEM_ZEROINIT)
'Initialize the Buffer Pointer
Dim ptrBuffer As IntPtr = IntPtr.Zero, ptrDomain As IntPtr = IntPtr.Zero
If (Not IsNothing(Domain)) AndAlso (Domain.Length > 0) Then
ptrDomain = Marshal.StringToBSTR(Domain)
ptrBuffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(vResource))
vResource.RemoteName = ptrDomain
Call Marshal.StructureToPtr(vResource, ptrBuffer, True)
End If
Try
hResult = WNetOpenEnum(ResourceScopes.resGlobalNet, ResourceTypes.resAny, ResourceUseages.resContainer, ptrBuffer, hEnum)
If (hResult = 0) And (hEnum <> 0) Then 'Successful
'Enumerate the Resource
hBuffer = GlobalAlloc(GPTR, nBufferSize)
hResult = WNetEnumResource(hEnum, nCount, hBuffer, nBufferSize)
If (hResult = 0) Then 'Successful
hPointer = hBuffer
For i = 0 To nCount - 1
'Retrieve the Information for the Resource
vResource = CType(Marshal.PtrToStructure(New IntPtr(hPointer), GetType(NETRESOURCE)), NETRESOURCE)
'Recurse to Find the Servers if this is a Root or Domain Node
Select Case vResource.DisplayType
Case ResourceDisplayTypes.resDomain, ResourceDisplayTypes.resGroup, ResourceDisplayTypes.resNetwork, ResourceDisplayTypes.resRoot
Call Me.RefreshServersWin9x(Marshal.PtrToStringAnsi(vResource.RemoteName))
End Select
'Determine the Next Pointer
hPointer += Marshal.SizeOf(vResource)
Next i
End If
End If
bInitialized = True
Catch
'Call Globals.ErrorMessage("Refresh")
Finally
'Free Up Memory
Call Marshal.FreeCoTaskMem(ptrBuffer)
Call Marshal.FreeCoTaskMem(ptrDomain)
If (hEnum > 0) Then hResult = WNetCloseEnum(hEnum)
If (hBuffer > 0) Then hResult = GlobalFree(hBuffer)
End Try
End Sub
|
|
|
|
|
maybe try posting this in the VB.NET section
Soliant | email
"The 'B' in Visual Basic means Beginner" - R. Bischoff
|
|
|
|
|
Nevermind, I figured it out!
|
|
|
|
|
The RichTextBox in .net doesn't do what I need- It doesn't let me disable AutoWordSelection (the API is broken), I can't change the default tab space size, I don't think I can rig it to do a line number gutter, and I don't think I can rig it to do syntax highlighting without distrupting the user typing.
That means I have to write a textbox from scratch. That will be a bigger job than the entire rest of my project.
Does anyone know of any tutorials and such about writing a custom textbox in C#/.net?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Well.
There are lots of sysntax highlighting tuts here and at www.codeguru.com[^] but I think they're all in C++. The actual highlighting isn't that big a deal. I've done it in VB with the normal VB rich text box for an SQL editor and that worked great.
As for the gutter, how about a richtextbox in a usercontrol. Size the control so it leaves the correct gap at the left side and draw your own line numbers there. You can get the size of the text and the number of lines down through the text the RTB is displaying etc etc etc, so that isn't that hard.
As for AutoWordSelection, uuummm, see what you mean.
Pete
Insert Sig. Here!
|
|
|
|
|
When you did syntax highlighting, were you able to do it while the user is typing? It seems like I have to select everything I want to change the color of, which would screw up typing...
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Bog wrote:
were you able to do it while the user is typing
Yup. Just disable drawing to the window so none of the results of your selection code is drawn while you're doing it. Then store the actual selection (which will probably just be the current caret location) then run your highlightiong code, changing the selection etc etc etc. Then resore the selection/caret etc and Re-enable drawing to the rich text window.
I handled a couple of cases
1) if the user is just typeing, only highlight the current line. This makes the hightlighting quick.
2) When the RTB gets pasted to, highlight the newly added parts or the whole document.
Have a look at the C++ examples to get a better idea of the process. Failing that, just have a go at it and see how it works.
Pete
Insert Sig. Here!
|
|
|
|
|
i wonder if its based on the real richtextbox - if it is you could just send it the messages to enable/disable the other features...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
The RichTextBox class constructor is not marked internal, so you can derive it.
I would suggest you download a free tool like Anakrino[^] to decompile the IL code to C#, as a help to override the methods.
How low can you go ? (MS rant)
|
|
|
|
|
Hi All,
Probably a stupid qustion but...
I've got an object that I'm displaying to the end user via a PropertyGrid control. One of the properties is a Password. I'd like to display this item as "*****" rather than visible text.
Is there anyway of doing this ?
Cheers .. Andy
|
|
|
|
|
You have to write a custom UI type editor[^]. (there is a sample).
How low can you go ? (MS rant)
|
|
|
|
|
Thanks for the info ... but the link doesn't work for me...
|
|
|
|
|
Well i've managed to find the info and i've tried it out.
The examples i can find give me the ability to render a UI component as a drop down or modal control. I've played with this and have been able to get a TextBox with a password mask just fine.
BUT ... the data in the PropertyGrid is still clear text ! Which is not what i want... this is the text that must be hidden.
Ideas anyone ?
|
|
|
|
|
I think you need a type convertor , not a UItype editor. Also the password have to be a class of its own (perhaps, maybe not) and not just a string.
Hope this helps
"There are no stupid question's, just stupid people."
|
|
|
|
|
Well, in the normal way, the property can be edited in a textbox, right?
So, we can change its default UITypeEditor to a TextBox which PasswordChar is * or any char you like, by setting some attributes like EditorAttribute on the property you have.
Hope helps to you.
I'm amumu, and you?
|
|
|
|
|
Hello Everybody,
I am trying to import data from Excel sheets through my application.But its not reding the first row of Excel sheet.
Somebody suggested me to set "HDR=No" property in my connection string.
So now my connection string looks as follows,
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source="+fullPath+";" +
"Extended Properties=Excel 8.0;HDR=No;";
but its giving me following exception
"System.Data.OleDb.OleDbException : Could not find
installable ISAM
at System.Data.OleDb.OleDbConnection.ProcessResults(Int32
hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
........"
To overcome this error i tried doing following things
I went to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel
location in my windows registery and found following things,
Name Type Data
win32 REG_SZ c:\WINDOWS\System32\msexcl40.dll
then I checked if this "msexcl40.dll" really exist at the path c:\WINDOWS\System32
and it was present there.
Then i uninstalled office2000 from my machine and installed OfficeXP.
Still i am getting the same exception.
Can anybody help me in finding out where i am going wrong or what could be the problem?
Thanks in advance,
Regards,
Saroj
Saroj
|
|
|
|
|
There can be many reasons. Reinstalling Office may not be enough, especially when you know that what you are actually using here is the MDAC run-time which is separately available.
I would suggest to install MDAC 2.7[^]
Other than that, msexcl40.dll has two MDAC child dll dependencies : msjet40.dll, mswstr10.dll
How low can you go ? (MS rant)
|
|
|
|
|
Where can i download the visual soucesafe 6.0c?Thanks.
|
|
|
|
|
i think it only comes with Visual Studio.NET Enterprise Edition, it is the piece that does all the integration work between VS.NET and the VSS database
Soliant | email
"The 'B' in Visual Basic means Beginner" - R. Bischoff
|
|
|
|
|
Someone please tell me if this is supposed to work:
(because it compiles and all I'm getting is a runtime invalid cast exception)
Object obj = someAssembly.CreateInstance("MyClass");
MyAbstractClass x = (MyAbstractClass) obj;
x.doCoolStuff();
More importantly, I don't want to use Invoke() calls. Isn't there a cleaner work-around?
Bilal
|
|
|
|
|
What's the definition of MyClass and MyAbstractClass?
Also, have you tried this without using CreateInstance to see if that works?
Cheers,
Simon
"VB.NET ... the STD of choice", Me, interal company memo
|
|
|
|
|
MyClass is derived from MyAbstractClass (sorry, should have mentioned that) and implements parent's abstract functions.
What alternatives are there for creating objects at runtime from definitions available only in other .NET DLLs or EXEs?
I'm just a .NET newbie
Bilal
|
|
|
|