From 29e2cadd1007cff64033ee951ccb37afd0ac5d1a Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Fri, 30 Jan 2015 10:35:48 +0000 Subject: [PATCH] - fixed home folder. Set to desktop - getNetworkAdapter() for generating initial FsTrack.kml (Zwischenstand) git-svn-id: http://moon:8086/svn/software/trunk/projects/FsTrack@174 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- Source/Main.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/Source/Main.cpp b/Source/Main.cpp index e5f397c..b344b8e 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -7,13 +7,12 @@ ============================================================================== */ -#include -//#include +#include +#include #include "../JuceLibraryCode/JuceHeader.h" #include "MainComponent.h" - //============================================================================== class FsTrackApplication : public JUCEApplication { @@ -24,7 +23,53 @@ public: const String getApplicationName() override { return ProjectInfo::projectName; } const String getApplicationVersion() override { return ProjectInfo::versionString; } bool moreThanOneInstanceAllowed() override { return true; } + static void getNetworkAdapters() + { + PIP_ADAPTER_INFO pAdapterInfo; + pAdapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof(IP_ADAPTER_INFO)); + ULONG buflen = sizeof(IP_ADAPTER_INFO); + if(GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) + { + free(pAdapterInfo); + pAdapterInfo = (IP_ADAPTER_INFO *) malloc(buflen); + } + + if(GetAdaptersInfo(pAdapterInfo, &buflen) == NO_ERROR) + { + PIP_ADAPTER_INFO pAdapter = pAdapterInfo; + while (pAdapter) + { + printf("\tAdapter Name: \t%s\n", pAdapter->AdapterName); + printf("\tAdapter Desc: \t%s\n", pAdapter->Description); + printf("\tAdapter Addr: \t%ld\n", pAdapter->Address); + printf("\tIP Address: \t%s\n", pAdapter->IpAddressList.IpAddress.String); + printf("\tIP Mask: \t%s\n", pAdapter->IpAddressList.IpMask.String); + printf("\tGateway: \t%s\n", pAdapter->GatewayList.IpAddress.String); + if(pAdapter->DhcpEnabled) + { + printf("\tDHCP Enabled: Yes\n"); + printf("\t\tDHCP Server: \t%s\n", pAdapter->DhcpServer.IpAddress.String); + printf("\tLease Obtained: %ld\n", pAdapter->LeaseObtained); + } else { + printf("\tDHCP Enabled: No\n"); + } + if(pAdapter->HaveWins) + { + printf("\tHave Wins: Yes\n"); + printf("\t\tPrimary Wins Server: \t%s\n", pAdapter->PrimaryWinsServer.IpAddress.String); + printf("\t\tSecondary Wins Server: \t%s\n", pAdapter->SecondaryWinsServer.IpAddress.String); + } else + { + printf("\tHave Wins: No\n"); + } + pAdapter = pAdapter->Next; + } + } else + { + printf("Call to GetAdaptersInfo failed.\n"); + } + } //============================================================================== void initialise (const String& commandLine) override { @@ -69,10 +114,14 @@ public: Colours::lightgrey, DocumentWindow::allButtons) { - PWSTR path; -// SHGetKnownFolderPath(FOLDERID_Profile, 0, NULL, &path); - - static String pathStr("C:\\Users\\jens"); + FsTrackApplication::getNetworkAdapters(); + + char path[1024]; + if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_DESKTOP, nullptr, 0, path))) + { + return; + } + static String pathStr(path); setContentOwned (new MainComponent(pathStr), true); centreWithSize (getWidth(), getHeight());