-
December 5th, 2007, 01:30 AM
#1
Win32 API support in MFC Dialog based application.
Dear Gurus,
I belive that MFC supports win32 API's. But the function "OpenSCManager() " is giving me the error, i included header file "Windows.h" also.
My question is whether we can use the "OpenSCManager()" function in MFC Dialog based applicaton.
Thank You,
Surender.
-
December 5th, 2007, 02:14 AM
#2
Re: Win32 API support in MFC Dialog based application.
MFC is just a framework built on top of the Win32 API. When using MFC there shouldn't be any trouble using Win32 API functions.
Have you checked this function requirements in the msdn database ?
Requires Windows Vista, Windows XP, or Windows 2000 Professional. Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server. Header Declared in Winsvc.h; include Windows.h.
Library Use Advapi32.lib.
DLL Requires Advapi32.dll.
Unicode Implemented as OpenSCManagerW (Unicode) and OpenSCManagerA (ANSI).
have you included the correct libs ? do you have access to the right dll ?
Regards,
Zachm
-
December 6th, 2007, 04:33 AM
#3
Re: Win32 API support in MFC Dialog based application.
HI Zachm,
Those libraries are there. To make sure that OpenSCManager() function working i have crated two dumy projects.
project 1: I have created a project using "Win32 console application" from the project menu. Here the OpenSCManager() function is working.
project 2: Created a project using "MFC Appwizard(exe)" . Her in this project the function OpenSCManager is not working.
This is the problem. Is there ang project settings i am missing...
pls suggest me hat i have to do.
Suren
-
December 6th, 2007, 04:44 AM
#4
Re: Win32 API support in MFC Dialog based application.
Originally Posted by A_Surender
HI Zachm,
Those libraries are there.
If they were, there would be no error.
First, what is the error that you're getting? You never mentioned anything except "it doesn't work". That is not enough information for us to tell you what is wrong.
Second, in the linker settings, are those libraries specified? If not, then add those libraries.
Third, including a header file only allows the source code to compile. After the compiling, the linker must find these functions implemented somewhere. If the linker can't find those functions, then you get a linker error. So just because you included a header file doesn't really mean anything when it comes to the link step when creating the executable.
Regards,
Paul McKenzie
-
February 15th, 2008, 06:52 AM
#5
Re: Win32 API support in MFC Dialog based application.
Hi,
I am sorry iam replying very lately.
The problem was at complie time. It saya the "Identifier is Undeclared". somehow that problem got solved by the time i returned from homtown.
Thank you for responding
-
March 10th, 2013, 07:08 AM
#6
Re: Win32 API support in MFC Dialog based application.
goto stdafx.h and comment the following line
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
-
March 11th, 2013, 10:23 AM
#7
Re: Win32 API support in MFC Dialog based application.
OpenSCManager() is available from Windows 2000 only.
If you're using a (very) old version of VS2010, then it won't be targetting above Win2000 by default, in fact, your platform SDK may not even have this function at all.
I would expect you will need VS2003 at least and in that version, you will need to set your platform targetting to Win2000 at least.
IIRC, in VS2005 you still needed to explicitely set windows version targetting to Win2000 as it targets Win98 by default.
-
March 11th, 2013, 11:07 AM
#8
Re: Win32 API support in MFC Dialog based application.
Originally Posted by OReubens
OpenSCManager() is available from Windows 2000 only.
I never used this API though, but my old MSDN from October 2000 show me the following information:
OpenSCManager
...
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Header: Declared in Winsvc.h; include Windows.h.
Library: Use Advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Victor Nijegorodov
-
March 14th, 2013, 03:06 AM
#9
Re: Win32 API support in MFC Dialog based application.
@VictorN & OReubens
[ off-topic ]
I noticed that newer versions of MSDN tend to eliminate references to older Windows versions. Possible, they want to place them in the Dark (Windows Programming) Ages.
For example, have a look at OpenSCManager function (Windows).
It states as minimum required OS Windows XP or Windows Server 2003.
Probably, 390 days from now, the "minimum required" for OpenSCManager will be Windows Vista or Windows Server 2008.
And so on...
But, without having a look in MSDN 2000, I'm sure it is supported in older NT versions, simply because I used OpenSCManager more than 15 years ago.
@A_Surender
[ on-topic ]
Do not include <Windows.h> in MFC applications. That usually generates a compiler error.
For OpenSCManager and related, include <Winsvc.h>, which also can be found in OpenSCManager documentation, under "Requirements".
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|