Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0

    Creating a locking program


    Hi. I wanted to create a locking program that stores information needed for another exe. When the person enters all the information needed and the file that he/she wants to lock, the exe file will create another exe file that stores all the information being typed previously and also the file. When the user double click on the exe, the exe will need the user to enter the required information before it lets the user use the file.

    How can I let the exe file create another exe which has a file in it?

    P.S. Someone must help mi cause this is my homework. By the way, I am trying to do this in C++.net. It is a MFC application. Thanks!!!
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    We don't do homework here. You can ask specific questions regarding code YOU wrote.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0

    Asking


    ok. I just want to know whether I can use an exe that is created by C++.net to create another exe out that has a file in it? If possible, are there any examples out there?
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    16
    Rep Power
    0
    WinExec (in the API) opens an executable:
    WinExec("gunzip *.gz", SW_SHOWNA);
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0

    Thanks


    Thanks for that. But how can I create an exe out from another exe (i don't wanna open an existing exe)?
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    16
    Rep Power
    0
    That's kind of what I'm working on. My plan now is to first create the second exe with empty variables, and then run it from the first exe using WinExec, and fill in the blanks and write to disk the image in memory of the second exe. Hopefully Windows will allow this.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0

    Thanks


    Thanks. By the way, if u r doing almost the same thing as mine, do u mind letting mi see ur codes as reference???
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    16
    Rep Power
    0
    This was the answer for my problem (making an Installer program), and I think it would also be the answer to your problem:

    if (hrsrc = FindResource(hInst, MAKEINTRESOURCE(IDR_DATA1), MAKEINTRESOURCE(BINTYPE)))
    hResource = LoadResource(hInst, hrsrc);//copy USAPhotoMaps.z into this exe file
    Buf = (BYTE*)LockResource(hResource);//point to it
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    16
    Rep Power
    0
    and this is the line in the .rc file:
    IDR_DATA1 BINTYPE "USAPhotoMaps.z"

    and this is in the resourch.h file:
    //{{NO_DEPENDENCIES}}
    // Microsoft Developer Studio generated include file.
    // Used by InstallUSAPhotoMaps.rc
    //
    #define IDR_DATA1 103
    #define IDC_RADIO1 1000
    #define IDC_RADIO2 1001
    #define IDC_TREE1 1002
    #define BINTYPE 1003
    #define IDR_BINTYPE1 1004

    // Next default values for new objects
    //
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE 104
    #define _APS_NEXT_COMMAND_VALUE 40001
    #define _APS_NEXT_CONTROL_VALUE 1005
    #define _APS_NEXT_SYMED_VALUE 101
    #endif
    #endif
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0
    For the code below:

    if (hrsrc = FindResource(hInst, MAKEINTRESOURCE(IDR_DATA1), MAKEINTRESOURCE(BINTYPE)))
    hResource = LoadResource(hInst, hrsrc);//copy USAPhotoMaps.z into this exe file
    Buf = (BYTE*)LockResource(hResource);//point to it

    Does the code mean that if it finds the resource, it will put the value into the other exe file? Also, do i create the second exe first and then hide it or throw into the first exe so that when the first exe has finished its task. it will throw out the second exe?
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    16
    Rep Power
    0
    Sorry, I don't know what you are saying. You'll have to find out on your own what those API's do.
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0

    ok


    ok. If that's the case, can u explain the code to mi in brief?
  24. #13
  25. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    16
    Rep Power
    0
    No. Read the book.
  26. #14
  27. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0
    ok. then can i ask how can we launch program from resources?
    (by the way, about the file USAPhotoMaps.z, is it that u create manually or it is created by the program?)

    P.S. I give u a more detailed idea of what I want to do. I have an exe file that shows a dialog. The user need to type in a product id, a vendor id and need to select a file to do the locking. When the user have have completed these tasks and clicked on the OK button, a dialog box (created by CFileDialog) will appear and ask the user where he/she want to save the second exe file to. After that, the first exe file will create the second exe file which will hold all the information that the user has typed and also the file that the user has selected previously.

    When the user open the second exe, it will need the user to type his/her username and password before he/she can open up the file which is attached to it.

    Can you give mi some ideas on the following:
    1) How can I create an exe file using another exe file?
    2) How can I attach a file to the second exe file?
    3) How to pass in the values from the first exe file to the second exe file?

    I really need your help. Please reply me A.S.A.P.
    Last edited by rickykoh1983; September 1st, 2003 at 04:05 AM.
  28. #15
  29. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    16
    Rep Power
    0
    "//copy USAPhotoMaps.z into this exe file" means copy USAPhotoMaps.z (the file I want to install after I un-compress it) into memory. "//point to it" means create a pointer that points to the beginning of it. USAPhotoMaps.z is the same as your exe file that you have to put the product id and vendor id in. After you put those it, you write it to disk like you would write anything else to disk from memory.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo