Click to See Complete Forum and Search --> : C++ VB installer stub comm
filburt1
Oct 12th, 2001, 01:55 PM
This thread is for those interesting in developing a Visual Basic installer stub. It will copy the VB runtimes, register any intrinsic control DLLs and OCXs, and shell out a "real" setup program written in VB and kill itself. This is similar to the "Please wait while Setup initializes" in a setup made by the Package and Deployment Wizard/Setup Toolkit.
sail3005
Oct 12th, 2001, 01:56 PM
It's probably gonna start out as c++ console i think.
Maybe we can add a GUI later if it actually works and stuff
filburt1
Oct 12th, 2001, 02:12 PM
It shouldn't need a GUI, except for a big ol' Cancel button. :)
sail3005
Oct 12th, 2001, 02:20 PM
ok, what are the exact files that you want it to copy?
filburt1
Oct 12th, 2001, 02:23 PM
The VB runtimes and enough dependencies to get a REALLY simple VB program up and running. The setup that I'll make will only use intrinsic controls and stuff. So far I think only MSVBVM50.DLL is needed (this is VB5).
sail3005
Oct 12th, 2001, 02:36 PM
ok, i see. something we could do is make a text file that the program reads to know which files to copy over. we could name it wahtever we want. But that would allow on;y the files the programmer needs to be copied copied over.
filburt1
Oct 12th, 2001, 02:59 PM
Which is fine.
sail3005
Oct 12th, 2001, 03:27 PM
exactly how much c++ do you know filburt?
filburt1
Oct 12th, 2001, 03:29 PM
I know REALLY simple stuff with pointers, and much more about File I/O, string/vector manipulation using the College Board AP Computer Science classes...
sail3005
Oct 12th, 2001, 03:34 PM
ok, so when do you want to start on this?>
filburt1
Oct 12th, 2001, 03:35 PM
I'll really get going tonight (USA EST) when I get home from my mentorship.
sail3005
Oct 12th, 2001, 04:09 PM
ok, good. i'll be on then, as i am sick and have not much else to do :(:D
sail3005
Oct 13th, 2001, 05:35 PM
anyone else wanna help?
filburt1
Oct 13th, 2001, 06:58 PM
'Kay, I'm ready to start this thang. BTW, I have Borland C++ 5.04 (which crashes under Windows XP :mad:).
filburt1
Oct 13th, 2001, 07:04 PM
// Visual Basic Installer Stub
// Designed for Visual Basic 5.0 and 6.0
// Copyright (c) 2001 Arien "filburt1" Talabac, "sail3005"
#include <iostream.h>
int main()
{
cout << "Work!" << endl;
}
I'm done!
:rolleyes: I dunno how to shell an outside app, there are like a million exec commands. :(
sail3005
Oct 13th, 2001, 10:18 PM
Originally posted by filburt1
'Kay, I'm ready to start this thang. BTW, I have Borland C++ 5.04 (which crashes under Windows XP :mad:).
one q...why aren't you using VC++?
filburt1
Oct 13th, 2001, 10:20 PM
Don't have it. BTW, the latest (obviously not anywhere near finished):
// Visual Basic Installer Stub
// Designed for Visual Basic 5.0 and 6.0
// Copyright (c) 2001 Arien "filburt1" Talabac, "sail3005"
// ap*.h classes are from the College Board; download them at
// http://www.collegeboard.org/ap/computer-science/html/classes.html
#include <iostream.h>
#include <fstream.h>
#include <windows.h>
#include <conio.h> // requires Borland compiler
#include "apstring.h"
#include "apvector.h"
#define _PROJECT_VERSION_ "1.0.0"
#define _SCRIPT_FILE_ "script.iss"
apstring WindowsSystemDirectory()
// Returns a path to the Windows system directory or "" on error.
{
UINT i;
char path[MAX_PATH];
UINT sz = MAX_PATH;
i = GetWindowsDirectory(path, sz);
return apstring(path);
}
int main()
{
cout << "Visual Basic Installer Stub" << endl;
cout << "Version " << _PROJECT_VERSION_ << endl;
cout << endl;
cout << "Searching for stub script \"" << _SCRIPT_FILE_ << "\"...";
ifstream in(_SCRIPT_FILE_, ios::nocreate);
if (in.fail())
{
cout << "Failed" << endl;
return 1;
}
cout << "Found" << endl;
cout << "Loading script commands...";
apstring currentLine("");
apvector<apstring> lines;
while (!in.eof())
{
getline(in, currentLine);
lines.resize(lines.length() + 1);
lines[lines.length() - 1] = currentLine;
}
in.close();
cout << "Loaded " << lines.length() << " directive(s)" << endl;
cout << "Executing directives..." << endl;
for (long i = 0; i < lines.length(); i++)
{
currentLine = lines[i]; // cache it for speed
if (currentLine.find("copytowinsysdir") == 0)
{
apstring source;
int spaceLoc = currentLine.find(' ');
if (spaceLoc != npos)
{
source = currentLine.substr(spaceLoc + 1,
currentLine.length() - spaceLoc);
cout << "Copying \"" << source
<< "\" to \"" << WindowsSystemDirectory() << "\"...";
cout << "Done" << endl;
}
}
else if (currentLine.find("copytowinsysdirandregister") == 0)
{
}
else if (currentLine.find("shellprocess") == 0)
{
}
else
{
cout << "Unrecognized directive \"" << currentLine << "\"" << endl;
}
}
cout << "Stub execution complete." << endl;
return 0;
}
sail3005
Oct 13th, 2001, 10:35 PM
Cool, looks like a great start. I am gonna go to bed soon, but i will work on what you have there tommarow, and see what i can hack out.
filburt1
Oct 13th, 2001, 10:40 PM
Okay. Here's a sample Installer Stub Script (.iss) file.
copytowinsysdir msvbvm50.dll
copytowinsysdirandregister specialsetupactivexcontrol.ocx
shellprocess "setup.exe"
sail3005
Oct 13th, 2001, 10:44 PM
looks great
one tip...
lets make the vars like this copyToWinSysDir msvbvm50.dll so it is more readable? is that ok?
filburt1
Oct 13th, 2001, 10:50 PM
Sure, I'll just make the code case insensitive. :)
Fencer5
Oct 14th, 2001, 05:46 PM
Sounds really cool... don't know much in C++, but I would be very interested in using the stub when you're done - with your name on it
filburt1
Oct 14th, 2001, 05:50 PM
DIE, Package and Setup Wizard! DIE! :D
Note that all this does is get a crutch up for a full-blown VB setup program.
Fencer5
Oct 14th, 2001, 07:30 PM
yeah - i know - i have one that i compiled in my age old version of QB4.5 (those were the days) - wouldn't mindd C++ one
filburt1
Oct 14th, 2001, 07:32 PM
QBasic couldn't do all the things we need like getting the system directory and checking if a file exists in a function (error trapping doesn't work in functions in QB :().
sail3005
Oct 14th, 2001, 08:06 PM
filb can you post the project in a zip file?
filburt1
Oct 14th, 2001, 08:13 PM
Here it is so far:
// Visual Basic Installer Stub
// Designed for Visual Basic 5.0 and 6.0
// Copyright (c) 2001 Arien Talabac
// ap*.h classes are from the College Board; download them at
// http://www.collegeboard.org/ap/computer-science/html/classes.html
#include <iostream.h>
#include <fstream.h>
#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#include "apstring.h"
#include "apvector.h"
#define _PROJECT_VERSION_ "1.0.0"
#define _SCRIPT_FILE_ "script.iss"
#define _WAIT_FOR_KEY_PRESS_TERMINATE_ true
#define _COPYRIGHT_NOTICE_ "Copyright (c) 2001 Arien Talabac"
// Uncomment below if bool is not a keyword in your compiler:
/*
#define bool int
#define true 1
#define false 0
*/
apstring windowsSystemDirectory()
// Returns a path to the Windows system directory or "" on error.
{
UINT i;
char path[MAX_PATH];
UINT sz = MAX_PATH;
i = GetWindowsDirectory(path, sz);
return apstring(path);
}
bool copyFile(const apstring &source, const apstring &dest)
// Copies source to dest and return true on success.
{
long flag = CopyFile(source.c_str(), dest.c_str(), FALSE);
return (flag != 0);
}
apstring lowercase(apstring s)
// Returns a lowercase version of s
{
for (int i = 0; i < s.length(); i++)
{
s[i] = tolower(s[i]);
}
return s;
}
bool executeScriptCommand(const apstring &s)
// Executes s and returns true on success.
{
if (s.find("copytowinsysdir") == 0)
{
int spaceLoc = s.find(' ');
if (spaceLoc != npos)
{
apstring source = s.substr(spaceLoc + 1, s.length() - spaceLoc);
apstring dest(windowsSystemDirectory() + "\\");
cout << "Copying \"" << source << "\" to \"" << dest << "\"...";
if (copyFile(source, dest + "\\"))
{
cout << "Done" << endl;
return true;
}
else
{
cout << "Failed" << endl;
return false;
}
}
else
{
cout << "Bad syntax in \"" << s << "\"" << endl;
return false;
}
}
else if (s.find("copytowinsysdirandregister") == 0)
{
}
else if (s.find("shellprocess") == 0)
{
}
else
{
cout << "Unrecognized directive \"" << s << "\"" << endl;
return false;
}
return true;
}
int main()
{
cout << "Visual Basic Installer Stub" << endl;
cout << "Version " << _PROJECT_VERSION_ << endl;
cout << _COPYRIGHT_NOTICE_ << endl;
cout << endl;
cout << "Searching for stub script \"" << _SCRIPT_FILE_ << "\"...";
ifstream in(_SCRIPT_FILE_, ios::nocreate);
if (in.fail())
{
cout << "Failed" << endl;
return 1;
}
cout << "Found" << endl;
cout << "Loading script commands...";
apstring currentLine("");
apvector<apstring> lines;
while (!in.eof())
{
getline(in, currentLine);
lines.resize(lines.length() + 1);
lines[lines.length() - 1] = currentLine;
}
in.close();
cout << "Loaded " << lines.length() << " directive(s)" << endl;
cout << "Executing directives..." << endl;
long errorCount = 0;
for (long i = 0; i < lines.length(); i++)
{
if (!executeScriptCommand(lines[i]))
{
errorCount++;
}
}
cout << "Done executing " << lines.length() << " directive(s) with "
<< errorCount << " error(s)" << endl;
if (_WAIT_FOR_KEY_PRESS_TERMINATE_)
{
getchar();
}
return 0;
}
sail3005
Oct 14th, 2001, 08:14 PM
thanks ;)
drcacho
Oct 19th, 2001, 11:29 AM
Try Inno setup at www.innosetup.com (http://www.innosetup.com/)
That's cool & free (Comes with sources!)
filburt1
Oct 19th, 2001, 11:30 AM
I know, but that's a full-blown setup package, this is just a stub to get a full-blown setup program written in VB up and running. :)
Sastraxi
Oct 19th, 2001, 11:30 AM
I may be looking into this... =)
eiSecure
Nov 24th, 2001, 07:11 PM
Filburt, is it finished yet?
Secure-It! 2002 SP1 is about to be released, and I want to create my own install.:):D
Hampster
Mar 6th, 2002, 07:49 PM
Hmm, haven't tested this out, but this looks like a way to see if a file exists in QB
http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/314/qid/191533
Osnr
Jan 1st, 2003, 09:48 PM
.iss is InnoSetup's extension! (Inno Setup Script) You'll have to get a new extension :)
Sastraxi
Jan 2nd, 2003, 01:29 AM
The project is dead.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.