PC Review


Reply
Thread Tools Rate Thread

How to #include <someheader.h> in the managed code?

 
 
Viktor
Guest
Posts: n/a
 
      14th Apr 2004
Hi everybody,
Perhaps this question is obvious, but I spent whole day trying to make
it work to no avail.

Here is the scenario:
I am using VC++ .Net, Forms. I created a simple Form project, dropped
couple of controls on the form. Now I am trying to call
GetProfileSection(...) to read values from .ini file. IDE seems to
know this function, since it shows parameter list as a tooltip as soon
as I type "GetProfileSection(".

But when I am trying to build it, I am getting "GetProfileSection:
identifier not found..." error. GetProfileSection is declared in
winbase.h, but if I try to add #include <winbase.h>, I am getting 78
errors in winbase.h, which cannot be true. Same happens with calls to
other functions, declared in other headers.

I was trying to find an explanation on a web but couldn't, although
there must be some simple explanation.

Any help would be greatly appreciated.

Viktor

Below is a top portion of my Form1.h, (the unit that contains buttons'
OnClick events etc, where I am trying to call GetProfileSection)

#pragma once

namespace Test1
{
#include<string.h>
#include <winbase.h> // Is this correct place to include .h?

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:ata;
using namespace System:rawing;
using namespace System::Collections;
using namespace System::Runtime::InteropServices;
 
Reply With Quote
 
 
 
 
Tomas Restrepo \(MVP\)
Guest
Posts: n/a
 
      15th Apr 2004
Viktor,
> Hi everybody,
> Perhaps this question is obvious, but I spent whole day trying to make
> it work to no avail.
>
> Here is the scenario:
> I am using VC++ .Net, Forms. I created a simple Form project, dropped
> couple of controls on the form. Now I am trying to call
> GetProfileSection(...) to read values from .ini file. IDE seems to
> know this function, since it shows parameter list as a tooltip as soon
> as I type "GetProfileSection(".
>
> But when I am trying to build it, I am getting "GetProfileSection:
> identifier not found..." error. GetProfileSection is declared in
> winbase.h, but if I try to add #include <winbase.h>, I am getting 78
> errors in winbase.h, which cannot be true. Same happens with calls to
> other functions, declared in other headers.
>
> I was trying to find an explanation on a web but couldn't, although
> there must be some simple explanation.
>
> Any help would be greatly appreciated.
>
> Viktor
>
> Below is a top portion of my Form1.h, (the unit that contains buttons'
> OnClick events etc, where I am trying to call GetProfileSection)
>
> #pragma once
>
> namespace Test1
> {
> #include<string.h>
> #include <winbase.h> // Is this correct place to include .h?


Don't include winbase.h, instead include windows.h. Also, move the #includes
to outside of the namespace declaration. In fact, you'd do better off just
moving them altogether to your stdafx.h precompiled header, it should speed
up your compile times.

--
Tomas Restrepo
(E-Mail Removed)


 
Reply With Quote
 
 
 
 
David Olsen
Guest
Posts: n/a
 
      15th Apr 2004
Viktor wrote:
> GetProfileSection is declared in
> winbase.h, but if I try to add #include <winbase.h>, I am getting 78
> errors in winbase.h, which cannot be true.


> Below is a top portion of my Form1.h, (the unit that contains buttons'
> OnClick events etc, where I am trying to call GetProfileSection)
>
> #pragma once
>
> namespace Test1
> {
> #include<string.h>
> #include <winbase.h> // Is this correct place to include .h?


Don't ever put an #include inside a namespace. All the included stuff
will be inside the namespace Test1, which is not where it is supposed to
be. Move the #includes to global scope, before "namespace Test1".

--
David Olsen
(E-Mail Removed)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling user control from VBScript (managed and un-managed) b.bardugo Microsoft Dot NET 2 17th Nov 2004 10:36 PM
Problem with calling a managed C++ function from managed C# Andre Microsoft C# .NET 2 2nd Aug 2004 02:24 PM
Difference in managed code and managed object Girish Microsoft Dot NET Framework 1 1st Dec 2003 09:16 AM
Difference between Managed Code and Managed Object Girish Tripathi Microsoft Dot NET Framework 1 27th Nov 2003 04:47 PM
.Net Framework Managed vis .Net Managed provider Ramesh Microsoft C# .NET 1 4th Sep 2003 09:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:07 AM.