Skip to main content
GameDev.net gamedev.net
🔒 Locked

[Win32 C++] Waaay out win32 functions NOT recognised

Started by gretty Nov 17, 2010 at 2:23 AM 2 replies 2.9k views
Original Post
gretty
gretty
Hello, I have a problem that has BEEN DRIVING ME CRAZY for months!! And the problem has to do with using a specific win32 function but my compiler telling me that function doesn't exist even when I import the correct library. Now I know of the reasons why I should not use dev c++, but this compile error happens across the board( codeBlocks, vc++ ).


I am trying to explore(code) the windows task manager BUT like many aspects of win32 when I try to use a specific win32 function, structure or constant my compiler tells me it doesn't recognise that function/structure/constant.

I seem to run into this problem(I have correct win32 code but it will not compile because X is not recognised by the compiler) alot & I am aware that msdn displays what libraries are required (to be imported) to use X function & I import the correct library but I either get a compiler error saying "comdef.h: No such file or directory" OR "ITaskService() undeclared(first use of this function)".

What do I need to do to get my compiler to recognise a win32 function, structure or constant?

Do I need to link to the absolute path of comdef.h, for example, #import ?? Do I need to define a specific version of windows before importing windows.h, for example, #define _WIN32_WINNT 0x0502 (although I have tried this already with no success). I am using Windows 7 64 bit.

An example is trying to compile the example code from msdn for using the Windows Task Manager, I copy & paste the c++ code exactly from msdn, paste into my IDE( devc++ ) & try to compile. And I get the errors:


Quote:

- "comdef.h: No such file or directory"

- "wincreddef.h: No such file or directory"

- "taskschd.h: No such file or directory"

- "ITaskService() undeclared(first use of this function)".

-.....
voguemaster
voguemaster
Although I haven't used the task manager in a programmatic way, I can suggest a few things because if I "get" MS's designer's head, you would probably communicate with the task manager using COM and I bet its a COM server.

So, check the following:

1. You need to include comdef.h in your stdafx.h file. Also, if you're using COM you might as well use ATL as it saves a ton of crap-issues so add something like this:


#include
extern CComModule _Module; // you usually need this if you're using CoCreateInstance on things. BTW, one cpp file has to have a real instance of a CComModule
#include

#include
#include


2. You might want to set ATL properties in the general project page (like ATL using shared library).

3. Most importantly, make sure you environment is setup correctly with respect for directories. If the compiler can't find comdef.h then its a problem with your include directories. Either fix VC++ or fix your project to have additional include dirs.

How did you install the SDK ? As part of VC++ or standalone ? Usually when you install using VC++ everything is correct (at least windows SDK stuff).
-----------------------------He moves in space with minimum waste and maximum joyGalactic Conflict demo reel -http://www.youtube.com/watch?v=hh8z5jdpfXY
Codeka
Codeka
Quote:
Original post by gretty
Do I need to link to the absolute path of comdef.h, for example, #import ?? Do I need to define a specific version of windows before importing windows.h, for example, #define _WIN32_WINNT 0x0502 (although I have tried this already with no success). I am using Windows 7 64 bit.
Sounds like you're using Visual Studio express and you don't have the Windows SDK installed.

Also, ITaskService is for accessing the Task Scheduler, not Task Manager (Task Manager is the program that lists running applications and processes, etc)
BitMaster
BitMaster
Quote:
Original post by gretty
my IDE( devc++ )

There is your problem right there. You are using a compiler and an IDE which has not been worked on for five years now and which was buggy and incomplete back then.

Do not use Dev-C++. Visual Studio Express is free. Eclipse with CDT might be worth a look if you do not want to use it. Plenty of other free alternatives exist as well. You can even use a text editor and compile everything by command line with (a current) g++, it will cause much less problems than trying to use Dev-C++.

Apart from the fact that Dev-C++ is buggy, too old and far from what is expected of an IDE nowadays, you also seem to be suffering from an old version of the platform SDK (hence the missing headers). Any new compiler will likely directly come with a new(isher) platform SDK and even if not there is a reasonable probability you can download a current version from Microsoft and get it to work.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.