View Single Post
Old Dec 6th, 2005, 5:54 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,075
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
A py2exe solution

It hasn't been much of a problem, I'm guessing mainly because people have found a simple solution around it. But instead ColdDeath coded a solution for me.

The problem was when py2exe compiles it's programs, it outputs like so:

Your Directory
- build
- dist
- - program
- - - program.exe

Which means every client will need to open up "Your Directory/dist/program/program.exe". Not very convenient.

With this simple C++ program at: http://1v7.com/drsane/py2exe_solution.zip,
#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
        char direct_ini_contents[1024];         /* declare file string */
        char cwd[1024];                         /* declare cwd string */
        char fileName[1024];                    /* declare filename string */

        ifstream the_file ("redirect.ini");     /* open file */
        the_file >> direct_ini_contents;        /* send contents of file to string */
        the_file.close();                       /* close file object */

        cwd[0] = system("cd");                  /* set cwd to the cwd string */
        sprintf(fileName, "START %s%s",  cwd, direct_ini_contents);

        system(fileName);                       /* run file */

        return 0;
}
It reads the contents of "redirect.ini", appends it to the current working directory, and opens that file.

So in redirect.ini you can put "program/program.exe", then place the exe in the main folder. When the user opens this exe, it'll actually open up the exe located inside the redirect.ini.

Not sure if you need it as well, but if so, thank ColdDeath!
Sane is offline   Reply With Quote