 |
|
 |
Hi there, i downloaded your example, and it worked well in my project. But, since I work with MS SQL Server, IBM DB2 and Sybase, I kind of needed to be able to see those servers too. Can anybody help me with that? Thanks
Thiago Berti Thomaz
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
:(I need find SQLSERVER by this codes but I doesn't it work...help me...
PS: SQLSERVER local work....and about SQLSERVER network workk....but the CoomboBox is null....
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Does anybody have a translation to VB.NET. I'm not a C# developer and do not have the time right now to learn.
James M. Dorame
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
You do not need to translate C# components to VB.NET and vice versa providing they use just the CLS of .Net. This component almost does, see the end for the correction.
Unpack the zip to your system, and add the project file contained within it to your solution and compile.
Now go to your VB WinForms project within the solution, expand references and choose this components project from the project tab.
It just so happens there is a slight oversight in this component that prevents it working. Open ServerList.cs and change the line
public enum ServerTypeEnum : uint
to
public enum ServerTypeEnum : long
As uint is not supported by the CLS.
[)amien
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
you've got to be kidding me...I can do this in like ten lines of code or less. This website is really starting to suck ass.
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
If you can do it in 10 lines of code or less post an article about it so we can all learn. Without that article myself and others will just write you off as another anonymous coward that can't take criticism.
James
Simplicity Rules!
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
Has anyone a working translation of this Code. The Problem is: I can compile the Code from shillin but I get no servernames and the "entriesread" variable is 0.
please help me with this Problem !!
Dumbatz
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I only need make the following change then works fine for the Release Version 1:
// public override void Dispose() // { // base.Dispose(); // components.Dispose(); // } //b2_to_v1 protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
Regards,
Shilin
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Marty,
Thanks for your work! It's helpful for passing an array of UDTs (structures) in an unsafe way although I am still looking for the safe managed way(how to pass a safearray of UDTs? http://www.csharphelp.com/board/read.html?num=1&id=7393&loc=0&thread=7393).
I have successfully converted the beta 1 version code to beta2 version.It works great.
[DllImport("netapi32.dll", CharSet=CharSet.Auto)] private static extern void NetApiBufferFree([MarshalAs(UnmanagedType.U4)]uint bufptr); [DllImport("netapi32.dll", CharSet=CharSet.Auto)] unsafe private static extern uint NetServerEnum([MarshalAs(UnmanagedType.LPWStr)] string ServerName, uint level, uint* bufptr, uint prefmaxlen, ref uint entriesread, ref uint totalentries, uint servertype, [MarshalAs(UnmanagedType.LPWStr)] string domain, uint resume_handle);
[System.Runtime.InteropServices.StructLayoutAttribute (LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct SERVER_INFO_101 { public int dwPlatformID; public int lpszServerName; public int dwVersionMajor; public int dwVersionMinor; public int dwType; public int lpszComment; } protected void GetServers() { string servername = null; uint level = 101, prefmaxlen = 0xFFFFFFFF, entriesread = 0, totalentries = 0; //uint servertype = 0x00000004, uint resume_handle = 0; cboServers.Items.Clear(); .... unsafe { //get a pointer to the server info structure SERVER_INFO_101* si = null; SERVER_INFO_101* pTmp; //temp p ointer for use when looping through returned (pointer) array
//this api requires a pointer to a byte array...which is actually a pointer to an array //of SERVER_INFO_101 structures //If the domain parameter is NULL, the primary domain is implied. uint nRes = NetServerEnum(servername, level, (uint *) &si, prefmaxlen, ref entriesread, ref totalentries, (uint)_ServerType, null, resume_handle); if (nRes == 0) { if ((pTmp = si) != null) //assign the temp pointer { for (int i = 0; i < entriesread; i++) //loop through the entries { try { //the lpszServerName member of the structure contains a pointer to //the server name string...MarshalAs the pointer from unmanaged //memory to a managed string IntPtr intPtr = IntPtr.Zero; intPtr = new IntPtr (pTmp->lpszServerName); cboServers.Items.Add(Marshal.PtrToStringAuto( intPtr));
} catch (Exception e) { MessageBox.Show(e.Message) ; } pTmp++; //increment the pointer...essentially move to the next structure in the array } } } NetApiBufferFree((uint)si); } } } }
Shilin
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
|
 |
|
 |
Hi
Has anyone explain me how I can call Win32 API function GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen) where PFIXED_INFO is typedef struct { char HostName[MAX_HOSTNAME_LEN + 4] ; char DomainName[MAX_DOMAIN_NAME_LEN + 4]; PIP_ADDR_STRING CurrentDnsServer; IP_ADDR_STRING DnsServerList; UINT NodeType; char ScopeId[MAX_SCOPE_ID_LEN + 4]; UINT EnableRouting; UINT EnableProxy; UINT EnableDns; } FIXED_INFO, *PFIXED_INFO;
and PIP_ADDR_STRING is typedef struct _IP_ADDR_STRING { struct _IP_ADDR_STRING* Next; IP_ADDRESS_STRING IpAddress; IP_MASK_STRING IpMask; DWORD Context; } IP_ADDR_STRING, *PIP_ADDR_STRING;
I can't (or I can't understand how to) declare correct structures PFIXED_INFO and PIP_ADDR_STRING.
Best regards, Dimon
|
| Sign In·View Thread·PermaLink | 1.67/5 |
|
|
|
 |