Indigo Rose Software

Go Back   Indigo Rose Software Forums > Indigo Rose Software > Developer's Den

Reply
 
Thread Tools Display Modes
  #1  
Old 07-22-2004
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
C++ question, how to get directory info...

OK so I'm creating a basic free add-on for AMS so people can add optional command line functionality to their apps. It's a small .exe which people can include (beside their autorun.exe) with their project that, when called, simply creates a .lua file at system root which contains the first command line parameter and then launches the autorun.exe (which detects/deletes that .lua file at startup) hidden. It's a learning excercise, but it could be cool for people to create multi-state or modal AMS apps, i.e. "Presentation Mode" or "Admin Mode", etc. according to command line switches. I remember someone asked for this a while back...

Anyhow OK so here's what I got so far, but I can't figure out how to use GetWindowsDirectory or even if that's what I should be doing. If anyone can help me figure out how to create the amsCmd.lua file automatically at %SYSTEMROOT% instead of c:\ that would be great. Thanks.

Code:
#include <iostream>
#include <windows.h>
#include <shellapi.h>
#include <fstream.h>

int main(int argc, char* argv[])  {

ofstream myCode ("c:\\amsCmd.lua");

  if (myCode.is_open())
  {
    myCode << "amsCmd=\"";
    myCode << argv[1];
    myCode << "\";";
    myCode.close();
  }

ShellExecute(0, "open", "autorun.exe", NULL, NULL, SW_HIDE);

return 0;

}
Corey Milner
Creative Director, Indigo Rose Software
Reply With Quote
  #2  
Old 07-22-2004
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Oh yeah. Here's two more cool things that I would appreciate if someone could show me:

1. How to make it loop through all parameters passed and write them to amsCmd.lua as a table instead of just writing the first one as a variable (as I have it).

2. Any possible ways to make this tinier in file size. The tinier the better.

Thanks, that should make for a nifty little command line wrapper add-on for AMS projects! Perfect for people who are building utilities, document viewers, or advanced media players, etc...

Corey Milner
Creative Director, Indigo Rose Software
Reply With Quote
  #3  
Old 07-22-2004
Worm Worm is offline
Indigo Rose Customer
 
Join Date: Jul 2002
Location: USA
Posts: 3,937
Code:
#include <iostream>
#include <windows.h>
#include <shellapi.h>
#include <fstream.h>

int main(int argc, char **argv) 
{
  ofstream myCode ("c:\\amsCmd.lua");

  if (myCode.is_open())
  {
     for(int i=1; i<argc, i++)
     {
       myCode << "amsCmd=\"" + argv[i] + "\";\n"; 
     }
    myCode.close();
  } 

  ShellExecute(0, "open", "autorun.exe", NULL, NULL, SW_HIDE);

  return 0;

}


Quote:
Originally Posted by Corey
OK so I'm creating a basic free add-on for AMS so people can add optional command line functionality to their apps. It's a small .exe which people can include (beside their autorun.exe) with their project that, when called, simply creates a .lua file at system root which contains the first command line parameter and then launches the autorun.exe (which detects/deletes that .lua file at startup) hidden. It's a learning excercise, but it could be cool for people to create multi-state or modal AMS apps, i.e. "Presentation Mode" or "Admin Mode", etc. according to command line switches. I remember someone asked for this a while back...

Anyhow OK so here's what I got so far, but I can't figure out how to use GetWindowsDirectory or even if that's what I should be doing. If anyone can help me figure out how to create the amsCmd.lua file automatically at %SYSTEMROOT% instead of c:\ that would be great. Thanks.

[code]
Reply With Quote
  #4  
Old 07-22-2004
TJ_Tigger's Avatar
TJ_Tigger TJ_Tigger is offline
Indigo Rose Customer
 
Join Date: Sep 2002
Location: Sol 3
Posts: 3,188
Code:
#include <iostream>
#include <windows.h>
#include <shellapi.h>
#include <fstream.h>

int main(int argc, char **argv) 
{
  ofstream myCode ("c:\\amsCmd.lua");

  if (myCode.is_open())
  {
     for(int i=1; i<argc, i++)
     {
       myCode << "amsCmd=\"" + argv[i] + "\";\n"; 
     }
    myCode.close();
  } 

  ShellExecute(0, "open", "autorun.exe", NULL, NULL, SW_HIDE);

  return 0;

}
It's all geek to me.
__________________
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
Reply With Quote
  #5  
Old 07-22-2004
Brett's Avatar
Brett Brett is offline
Indigo Rose Staff Member
 
Join Date: Jan 2000
Posts: 2,001
Corey, what would be the difference between using your app over the built-in _CommandLineArgs table in AMS50?

To use GetWindowsDirectory:

Code:
char szFolderName[MAX_PATH];
GetWindowsDirectory(szFolderName,MAX_PATH);
// Now you have the windows folder in szFolderName
Reply With Quote
  #6  
Old 07-22-2004
Worm Worm is offline
Indigo Rose Customer
 
Join Date: Jul 2002
Location: USA
Posts: 3,937
I was wondering the same thing, but assumed it was for the learning experience.

Quote:
Originally Posted by Brett
Corey, what would be the difference between using your app over the built-in _CommandLineArgs table in AMS50?

To use GetWindowsDirectory:

Code:
char szFolderName[MAX_PATH];
GetWindowsDirectory(szFolderName,MAX_PATH);
// Now you have the windows folder in szFolderName
Reply With Quote
  #7  
Old 07-22-2004
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Yeah, the only way I can learn is by making stuff. I didn't think there was a way to automatically run an app completely hidden when _CommandLineArgs is present, so I thought this might do that.

Tigg. Me 2.

Corey Milner
Creative Director, Indigo Rose Software
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
INFO: JET and MDAC (Complete) Runtime Notes Desmond Setup Factory 6.0 Knowledge Base 0 11-28-2003 09:35 AM
INFO: JET 4.0 SP7-SP8 Runtime Notes Desmond Setup Factory 6.0 Knowledge Base 0 11-28-2003 09:34 AM
INFO: How to Set the Default Application Directory Support Setup Factory 6.0 Knowledge Base 0 09-25-2002 01:02 PM
HOWTO: Install Files to the Windows Directory Support Setup Factory 6.0 Knowledge Base 0 09-18-2002 03:33 PM
data directory question Michael AutoPlay Menu Studio 3.0 3 02-12-2001 01:42 PM


All times are GMT -6. The time now is 07:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software