winapi first time

This is a discussion on winapi first time within the C++ Programming forums, part of the General Programming Boards category; Code: #include <windows.h> #include <fstream.h> #include <conio.h> int WINAPI WinMain(HINSTANCE hThisInstan, HINSTANCE hPrevInsta, LPSTR lpszArgument, int nShow) { ofstream fout; ...

  1. #1
    Unregistered
    Guest

    winapi first time

    Code:
    #include <windows.h>
    #include <fstream.h>
    #include <conio.h>
    
    int WINAPI WinMain(HINSTANCE hThisInstan, HINSTANCE hPrevInsta, LPSTR lpszArgument, int nShow)
    {
    
    ofstream fout;
    fout.open("hidden.txt");
    fout<<"An easy way to make your program run in the background!"<<endl;
    fout.close();
    
    return 0;
    }
    here are the errors i get
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/Text1.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    what do i need to do to get this to compile?

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    are you linking the libraries? maybe in the wrong order?

  3. #3
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    You are probably trying to compile a console application. It looks for a main() function, doesn't find it, and cries.

    Make sure to set your compiler target to Win32.

  4. #4
    Unregistered
    Guest
    Originally posted by Imperito
    You are probably trying to compile a console application. It looks for a main() function, doesn't find it, and cries.

    Make sure to set your compiler target to Win32.
    im using msvc++ 6.0

    i tried to make a win32 apllication but its still complaining about the same errors :P

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    all that happens when you create a windows application is that the program is run without the console appearing. make sure youre linking the libraries correctly.

  6. #6
    Unregistered
    Guest
    Originally posted by Flikm
    all that happens when you create a windows application is that the program is run without the console appearing. make sure youre linking the libraries correctly.
    how do i make sure the librairies are liken properly?

  7. #7
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163
    did you get that code from the forum on hack3r.com?
    +++
    ++
    + Sekti
    ++
    +++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 10:42 AM
  3. Is this really true or it's just science fiction?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 145
    Last Post: 04-09-2002, 06:17 PM
  4. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 09:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21