Article View: borland.public.cppbuilder.nativeapi
Article #9511Re: Connecting to external network via RAS
From: Oren Halvani
Date: Tue, 06 Jul 2004 22:27
Date: Tue, 06 Jul 2004 22:27
120 lines
5001 bytes
5001 bytes
hi nicolasr,
1.)
/**********************************************************/
#include <wininet.h>
void __fastcall TfrmInfo::EnumNetRes(NETRESOURCE* nr)
{
String NetStr = "Network Resources: "; HANDLE hEnum;
//NetResource=NULL : we want to enumerate all resources
if(WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_ANY,RESOURCEUSAGE_CONTAINER|RESO
URCEUSAGE_CONNECTABLE,nr,&hEnum)!=NO_ERROR)
{return;}
DWORD Count=-1; DWORD BufferSize=0; DWORD ReturnVal=0; //Enum all resources
NETRESOURCE *NetRes=(NETRESOURCE*)new char[1024];
ZeroMemory(NetRes,sizeof(NETRESOURCE));
for(;;)
{
ReturnVal=WNetEnumResource(hEnum,&Count,NetRes,&BufferSize);
if(ReturnVal==ERROR_MORE_DATA) //we set the size of NetRes
{
Count=-1; delete[] NetRes; //we set the size of NetRes if there is more
data
NetRes=(NETRESOURCE*)new char[BufferSize];
ZeroMemory(NetRes,sizeof(NETRESOURCE));
ReturnVal=WNetEnumResource(hEnum,&Count,NetRes,&BufferSize);
}
if(ReturnVal!=NO_ERROR)break;
for (unsigned int i=0;i<Count;i++)
{
txtSystem->Lines->Add(NetStr + NetRes[i].lpRemoteName);
Application->ProcessMessages();
if((NetRes[i].dwUsage & RESOURCEUSAGE_CONTAINER)==RESOURCEUSAGE_CONTAINER)
EnumNetRes(&NetRes[i]);
}
if(ReturnVal==ERROR_NO_MORE_ITEMS)
{
delete[] NetRes;
WNetCloseEnum(hEnum);
}
}
delete[] NetRes;
WNetCloseEnum(hEnum);
}
// Call with: EnumNetRes(NULL);
/**********************************************************/
2.) yes you can access them via their UNC name.
3.) hmmm..yes it's possible..here you go:
/**********************************************************/
String __fastcall TForm1::Get_OperatingSystemInfo(bool display_info)
{
OSVERSIONINFO vInfo;
ZeroMemory(&vInfo, sizeof(OSVERSIONINFO));
vInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
String S_os, S_majorv, S_minorv, S_build, OS_type;
if (GetVersionEx(&vInfo))
{
S_os = "Microsoft Windows ";
switch (vInfo.dwPlatformId)
{
case VER_PLATFORM_WIN32s : S_os += "3.1"; OS_type = "3.1"; break;
case VER_PLATFORM_WIN32_WINDOWS :
if(vInfo.dwMajorVersion == 4 && vInfo.dwMinorVersion == 0) {S_os += "95
";
if(vInfo.szCSDVersion[1] == 'C') {S_os += "OSR2"; OS_type = "OSR2";
break;}}
if(vInfo.dwMajorVersion == 4 && vInfo.dwMinorVersion == 10) {S_os +=
"98";
if (vInfo.szCSDVersion[1] == 'A') {S_os += "SE"; OS_type = "SE";
break; }}
if (vInfo.dwMajorVersion == 4 && vInfo.dwMinorVersion == 90) {S_os +=
"ME"; OS_type = "ME"; break; }
case VER_PLATFORM_WIN32_NT :
if(vInfo.dwMajorVersion == 3) {S_os += "NT 3.51"; OS_type = "NT 3.51";
break; }
if(vInfo.dwMajorVersion == 4) {S_os += "NT 4.0"; OS_type = "NT 4.0";
break; }
if(vInfo.dwMajorVersion == 5 && vInfo.dwMinorVersion == 0) {S_os +=
"2000"; OS_type = "2000"; break;}
if(vInfo.dwMajorVersion == 5 && vInfo.dwMinorVersion == 1) {S_os +=
"XP"; OS_type = "XP"; break;}} }
if(display_info) {S_majorv =
FormatFloat("0",(double)vInfo.dwMajorVersion); S_minorv =
FormatFloat("0",(double)vInfo.dwMinorVersion);
S_build =
FormatFloat("0",(double)vInfo.dwBuildNumber);
txtSystem->Lines->Add("Operating System: " + S_os + ", " + "Version " +
S_majorv + "." + S_minorv + " , " + "Build " + S_build);}
return OS_type;
}
// Call with: Get_OperatingSystemInfo(1);
/**********************************************************/
"nicolasr" <nicolasrNOSPAMATSIGNgmx.net> schrieb im Newsbeitrag
news:40eb2411$1@newsgroups.borland.com...
> 1) How can I enumerate existing shares on each of the computers?
>
> 2) Can I access files on the computers via UNC paths given the IP
> and a share-name? (like \\X.X.X.X\MyShare\SomeDir\test.txt)
>
> 3) Is it possible to determine the Windows version running on
> each of the computers?
Technical Details
Message-ID:
<40eb27d0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40eb2411$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,85f4e9c04dd4597f X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Oren Halvani" <NoSpam@fdtd.com> From: "Oren Halvani" <NoSpam@fdtd.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40eb2411$1@newsgroups.borland.com> Subject: Re: Connecting to external network via RAS Date: Wed, 7 Jul 2004 00:27:51 +0200 Lines: 122 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 217.234.95.198 Message-ID: <40eb27d0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1089152976 217.234.95.198 (6 Jul 2004 15:29:36 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail