Thread: autorun app

  1. #1
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429

    autorun app

    Hey all,

    Hammer gave me this code to use in a small app that will be used in a cd autorun.inf file. I can get it to compile, but it errors out when I try to build it with this error:

    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/AutoStart.exe : fatal error LNK1120: 1 unresolved externals
    Code:
    #define STRICT
    #include <Windows.h>
    /* */
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow)
    {
    int i;
    for (i = 1; i < __argc; i ++)
    {
    if ((int) ShellExecute(NULL, NULL, __argv[i], NULL, NULL, SW_SHOWNORMAL) <= 32)
    {// Error trying to run default browser, tell user
    CHAR sz[1024];
    wsprintf(sz, TEXT("Error openning %s on CD-ROM disc."), __argv[i]);
    MessageBox(NULL, sz, TEXT("ShellExecute"), MB_OK | MB_ICONWARNING);
    }
    }
    return(0);
    }
    help?

  2. #2
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    I'm new to c++, but I'm wondering... do I need a Main to call that API??

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    This belongs in the Windows development forum.

    Your compiler expects main() to be the program's entry point, not WinMain().

    Just change it to
    Code:
    int main(int argc,char *argv[])
    Be sure to changes references to "__argc" and "__argv" to "argc" and "argv".

    gg

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    If you do that it will become a console app, which is a bit yak for what you want.

    Better just compile it as a windows app in the first place. What compiler are you using?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    sweet... thanks. Sorry about posting in the wrong forum.. I wasn't sure where to put it.

  6. #6
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    MSVC 6

    I didn't know you had to compile it differently.

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    They'll be an option in the compile settings to create a console or a GUI app. You need GUI.

    I can't guide you any further with MSVC6, I'm one of the few people in the world that doesn't have it But I'm sure someone else will step in and advise.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I found it.....(finally)

    http://msdn.microsoft.com/library/de....SUBSYSTEM.asp

    You probably won't have to create a new project. Just go to Project->Settings->Link->(Category)General, down in the Project Options edit box, you should see "/subsystem:console". Change "console" to "windows".

    I did that to my console app and got:

    LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

    gg

  9. #9
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    go to new---win32 application (should be right above win32 console application) ---select standard (second option) and put the code into that project.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  2. best program to start
    By gooddevil in forum Networking/Device Communication
    Replies: 4
    Last Post: 05-28-2004, 05:56 PM
  3. Need help migrating console app to windows app
    By DelphiGuy in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2004, 07:05 PM
  4. pasword app
    By GanglyLamb in forum C Programming
    Replies: 2
    Last Post: 06-07-2003, 10:28 AM
  5. How do I make my Linux app standalone?
    By Joda in forum C++ Programming
    Replies: 2
    Last Post: 11-27-2002, 04:53 AM