Thread: Convert DOS source to Windows

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    6

    Thumbs up Convert DOS source to Windows

    Hello there =)
    I have the source for a small dos program and i would like to convert it to a windows program so i can put it in the tray or have it run as a service.
    Does anyone know how i can accomplish this ? =)
    Any help/input would be appreciated emmensly =)

    -Stephen

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Read this.
    Use WinMain instead of main (search for it on the above).
    Also read up on window procedures (WindowProc) and message loops.

    Failing that, post some code, ideally in the Windows Programming board.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    6

    Exclamation

    ok =)
    i found an int main2 in there as well, what about main2 ?

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Where, in your code? As far as I know there's no requirement of main2 for anything, so it's probably just a badly-named function.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    6
    this is its first appearance
    Code:
    int main2(int argc,uchar *argv[])
    { 
    lots of code 
    }
    and then here

    Code:
    // bic -> int main(int argc,uchar *argv[])
    int WinMain(int argc,uchar *argv[])
    {
    #ifdef PROTECT
        // REMOVED: exe integrity check
    #endif
        return(main2(argc,argv));
    }
    i guess its a func specific to this program that doesnt need to be changed? =)
    im a newb, sorry =)

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    That appears to be a passthrough, in that it passes the arguments used to start the program (main) directly to this second function main2. Really though, I wouldn't do it like that. This "EXE integrity check" thing should be stored in a function rather than clogging up main (Which, I'll have to assume, was the reason for main2).

    You should be able to cut the code from main2 and paste it into main, deleting main2 in the process.

    Also, WinMain is defined in the MSDN library as:-
    Code:
    int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
    It's not a case of just changing the name of the function, these arguments are specific to Windows. If you get errors after making this change, have you included windows.h (i.e. "#include <windows.h>" should be at the start of the code)?

  7. #7
    Registered User
    Join Date
    Mar 2005
    Posts
    6
    EFNet toke
    QuakeNet tokemon
    msn wordhole AT hotmail DOT com
    icq 2185413
    got paypal ? =)

  8. #8
    Registered User
    Join Date
    Mar 2005
    Posts
    6
    okey i removed main2 and moved it to WinMain
    i get 23 error(s), 15 warning(s) now =)
    windows.h was already included

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Great. Now how about you take the first error or warning, and fix that. Repeat that process until all of your errors and warnings are gone.

    Oh, I suppose you expected me to pull the answer out of my ass or something, right? I mean really, you didn't expect us to provide you with an answer just because you gave us the number of errors and warnings, did you?

    You did, didn't you? Now that's just sad.

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Registered User
    Join Date
    Mar 2005
    Posts
    6

    Unhappy

    no
    so there is no 'that'

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Simply renaming your DOS 'main' into a windows 'winmain' isn't going to make it any less DOS-like than it already is.

    More likely, it simply isn't going to work as you would expect, since windows programs are fundamentally different from console programs.

    Your best bet is to locate some particular magic on the net somewhere which allows you to wrap up DOS programs as a win32 service.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  2. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  3. accessing windows (98) memory from a dos box?
    By thedumbmutt in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 05-12-2003, 12:50 PM
  4. DOS experience 0 windows experience help
    By shrin2000 in forum Windows Programming
    Replies: 5
    Last Post: 07-15-2002, 02:22 AM
  5. Replies: 2
    Last Post: 12-31-2001, 08:23 PM