|
#1
|
||||
|
||||
|
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;
}
Creative Director, Indigo Rose Software |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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:
|
|
#4
|
||||
|
||||
|
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;
}
__________________
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 |
|
#5
|
||||
|
||||
|
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 |
|
#6
|
|||
|
|||
|
I was wondering the same thing, but assumed it was for the learning experience.
Quote:
|
|
#7
|
||||
|
||||
|
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 |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
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.









Linear Mode

