Visual C++ 6.0 question regarding WinAPI

  • Videogamer555
    6th Oct 2013 Member 0 Permalink
    Specifically I'm talking about the GetTickCount() API function (though this problem might be present in other WinAPI functions as well). By the way my system is Windows 7 Home Premium x64 (not sure if that makes a difference or not in this case).

    I've got this code here

    int main(int argc, char* argv[])
    {
    unsigned long a = GetTickCount();
    }

    It is supposed to assign the variable "a" the value of the current number of milliseconds since the computer was last booted. However instead it throws this error when compiling the code:
    error C2065: 'GetTickCount' : undeclared identifier

    I know that the Visual C++ 6.0 IDE recognizes the GetTickCount comand because when I type in GetTickCount() it immediately shows a popup that says "DWORD GetTickCount(VOID)". The fact it knows how the function is defined, means it can access the function, which in turn means it SHOULD be able to access the function when compiling. But for some odd reason it can't. It gives the above mentioned error when compiling.

    Can someone here with some Visual C++ 6.0 experience tell me what I'm doing wrong?

    Edited 2 times by Videogamer555. Last: 6th Oct 2013
  • boxmein
    6th Oct 2013 Former Staff 0 Permalink
    @Videogamer555 (View Post)
    Unrelated, but why VC++ 6.0? you can get VS C++ 10.0 for free and VS12 is out by paid means...
    The below code worked just fine for me, make sure you have your code set up similarly if you're unwilling to paste the entire thing somewhere:

    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include <stdio.h>

    // > this file: test_gettickcount.c
    // > cl version: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
    // > vcvars32.bat; cl test_gettickcount.c; test_gettickcount.exe
    // 4174243

    int main () {
    printf("%d", (int) GetTickCount());
    }
    Edited 3 times by boxmein. Last: 6th Oct 2013
  • Videogamer555
    7th Oct 2013 Member 0 Permalink
    Your code fails miserably! It generates this error.

    fatal error C1010: unexpected end of file while looking for precompiled header directive


    I assume this may be valid code for VC++ from VS10 or VS12. But it fails in VC++ 6. Maybe you can try to figure out how to do the same thing on a copy of VC++ 6. If you don't have it you can buy it somewhere if you are lucky (though I don't think MS sells it anymore). If you can't find a copy for sale anywhere, you can always get the torrent like I did (though I'm not gonna provide any such links to such websites here, just Google it if you want to find it)
    Edited once by Videogamer555. Last: 6th Oct 2013
  • MiningMarsh
    7th Oct 2013 Member 1 Permalink

    Why stick with VC++6 if you don't mind us asking?

  • Videogamer555
    7th Oct 2013 Member 0 Permalink
    I stick with it because it is the simplest programming language capable of making STDCALL DLL files that work with VB6. This allows me to extend the functionality of VB6 (potentially by quite a lot). VB6 is my favorite programming language, as it can do lots of stuff, and with DLLs and OCXs its capability can be extended to do almost anything you can imagine. Unlike newer versions of VB like .net and 2010, VB6 is capable of running with or without any version of .net Framework. Any newer version of VB requires the .net Framework, which can take hours to install. Also not everyone has the .net Framework runtimes needed to run software made in newer versions of VB. VB6 programs however will run on almost any computer, from Windows 98, up to Windows 7 (and possibly 8, though I don't have a Win8 computer to test it on). All you need for VB6 programs to run are the VB6 runtimes and any extra DLL or OCX files that it may use (and these can be packaged into a standard installer setup.exe with the Package and Deployment Wizard that comes with VB6). VB6 programs therefore have the widest compatability of any program made. Also newer versions of VB are bloated with WAY to much functionality. VB6 is straight to the point, and VERY easy to program with (far easier to use than any version of C). I prefer it over any version of C (including VC++ 6), however I find that using VC++6 can be useful for creating DLL files that can extend the functionality of VB6, which is why I have any interest at all in VC++6. I have yet to find one person on here who can answer my question? Is that because VC++6 is so old that people have forgotten how to use it and how to overcome any bugs/nuances it may present? (bugs/nuances awhich I seem to be constantly running into, and need significant help with overcoming).
  • MiningMarsh
    7th Oct 2013 Member 0 Permalink

    Heh, actually, VB6 is being dropped after windows 8, so it won't be around forever.

     

    Linux now fully supports compiling and running VB.Net through mono, so VB.Net very easily has more compatibility than VB6. I can run VB.Net code, but not your terrible VB6 code (and VB6 is a very very terrible language, at least VB.Net has .Net access...).

     

    As far as being bloated, the .Net framework is a system level thing with hooks in PowerShell, VB, C#, etc. It is not really fair to call that bloated, it would be like calling libc bloated: Almost every feature of it is used in at least one program, so any "bloat" is perfectly justified because of how much use it gets, and how well it gets its job done.

     

    And .Net does not really take hours to install considering windows comes with it and it is needed for core windows functionality, or the fact that it installed on my XP box in 10 minutes.

     

    And yeah, XP supports VB.Net, and last I checked something like 70% of the planet was running it, so you have no justification for using VB6 for compatibility.

     

    I am not saying you have to move to VB.Net, but don't expect any help for such an outdated API.

     

    Extend all I have said to VC++ 6 except for the horrible language bit, afaik VC++ 6 is still C, so the language itself is not all that terrible, just horribly outdated.

    Edited once by MiningMarsh. Last: 7th Oct 2013
  • mniip
    7th Oct 2013 Developer 0 Permalink
    VB6's syntax is totally bloated, every imaginable thing is an operator