Avatar of Jai Sewell
Jai Sewell
 asked on

Convert GUI app into console app for Win32 Env

Hi all!,
 I was wondering if anyone out there would be willing and would be so kind to give me some pointers or to help me convert a GUI C++ program into a console (CMD.exe) style application that will run on a Windows XP box...

The program that i am looking or hoping to convert can be found at the following link :
 http://www.codeproject.com/Articles/577445/Querying-Wireless-Settings-and-Decrypting-Wireless

I have no idea what i am doing in C as i have only ever used Delphi 4, Delphi 6, VB3, VB6, PHP, Javascript and HTML (but as you would have gathered by that, i have a reasonable understanding of programming principles)

anyhow, i will leave it at that and i will be eagerly awaiting a reply from anyone :)
DelphiMicrosoft Development

Avatar of undefined
Last Comment
Jai Sewell

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Sinisa Vuk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jai Sewell

ASKER
That works quite well but is not quite there yet...

I would like to decrypt the hex code in the windows xp registry that stores the saved wifi password, however this cannot be decrypted to a clear text ascii value, i know for certain that it can be converted to a 64 part hexadecimal value (just like NirSoft's WirelessKeyView does), i will paste up a whole heap of stuff i have gathered together in an attempt to demonstrate what i mean...

the follow hex is converted to the 64 part hex :
C8 02 00 00 03 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 74 65 73 6C 61 73 6F 75 72 63 65 73 2E 63 6F 6D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0
0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 65 B9 D7 BE 1C D2 01 03 00 00 80 00 00 00 00 01 00 00 00 D0 8C 9D DF 01 15 D1 11 8C 7A 00 C0 4F C2 97 EB 01 00 00 00 7A 4F 87 A7 63 9A 26 4F AC C0 B7 DE 77 A5 22 66 00 00 00 00 02 00 00 00 00 00 03 66 00 00 A8 00 00 00 10 00 00 00 38 63 D1 60 FC 12 BD 00 DD 30 CD 0D 4D 3A 39 7A 00 00 00 00 04 80 00 00 A0 00 00 00 10 00 00 00 9F 9D F0 DB 34 EC B8 6F 8E BE 9E 82 A5 DC 1E 29 28 00 00 00 73 1C C6 88 7B 81 A1 2D 08 34 FA 6F B6 19 2B BD FF AF 44 E2 69 9D B8 A4 24 FE 7E 9D 8A 87 64 AB 71 59 74 A5 DA 28 2B C4 14 00 00 00 86 B6 8F D4 06 CA C4 B9 B5 83 84 78 55 F6 7D E0 A6 25 11 41

and the 64 part hex looks like :
fbf59171ee510db622f1a335a0dc86328b24cd7b12f705e4cb2cf72a0d496dfd

and the windows xp registry key is :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces\{32F9DEC7-9EC8-4972-A7D9-28C9624DD331}
Jai Sewell

ASKER
Just run you're code again after i had the epiphany whilst laying in bed trying to get to sleep... to run the code with administrator privilege and it works bloody perfect!...
I must thank you Sinisa!.
And for anyone looking to use this code, it surely does work!, i used it in Delphi Enterprise 6 (6.163) on Windows 7 Ultimate 64bit... oooh and please also note that you will need an active wireless adapter, if you dont, then you simply wont get the codes (fully decrypted to i might add!, which far exceeded what i thought i would be able to accomplish, but please note that in WinXP it is impossible to fully decrypt the hex values from the registry to the original clear text password but you will get a 64 part hex value that you can use as the password instead, like WORD!, enter this 64 part hex value as the wifi password and you will be granted authorization and access!).

To start a Delphi app with escalated privilege by default (run as admin, simply by executing the app!, without changing "Compatibility settings/options" or right-clicking and selecting "Run as Administrator" ), please use the following code from stackoverflow post http://stackoverflow.com/questions/14703013/adding-manifest-for-admin-rights-request.

Create the following files uac.manifest, uac.rc, uac_xp.manifest and uac_xp.rc
Enter the code below for each file starting with uac.manifest, then uac.rc etc...

-uac.manifest

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="MyApp" type="win32"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

-uac.rc

1 25 "uac.manifest"

-uac_xp.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="MyApp" version="1.0.0.0" processorArchitecture="x86"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <!-- Windows Vista application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--Windows 7-->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!--Windows Vista-->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
    </application>
  </compatibility>  
</assembly>

-uac_xp.rc

1 24 "uac_xp.manifest"


Now add the desired rc file (uac.rc or uac_xp.rc) to your project via the "Project > Add to project" menu item. This will create the {$R} directive in your project file:

program Project1;

{.$R 'uac.res' 'uac.rc'} // UAC only
// OR
{$R 'uac_xp.res' 'uac_xp.rc'} // UAC + XP Themes

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
Jai Sewell

ASKER
But this code does not work with WinXP as i had originally asked!, please note that people, if you try you get an error that says wlanapi.dll could not be found!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes