Newbee Visual C++ Question -- GetWindowsDirectory()

  • Thread starter Harry Whitehouse
  • Start date
H

Harry Whitehouse

Hi!

I've fired up my first Visual C++ .NET (Version 7) project and have made
some nice progress. However, I'm now trying to call the familiar
GetWindowsDirectory() API.

When I'm laying in the code, the editor recognizes the function (it is
prompting me for the proper parameters) but when I compile I get "Error
3861: 'GetWindowsDirectory' : identifier not found, even with argument
dependent lookup".

I'm making the call just after InitializeComponent() in my initial form:

GetWindowsDirectory(WindowsDirectory,sizeof(WindowsDirectory));

I've defined the receiving buffer as a char array (perhaps this is one
problem):

char WindowsDirectory[_MAX_PATH]="";

and I've tried locating this declaration at various places through the my
form1.h file.

Removing the API call results in a successful compilation and link.

Can someone see what I'm doing wrong? It could be a real bone-head
mistake -- I'm new to this development environment.

TIA

Harry
 
W

William DePalo [MVP VC++]

Harry Whitehouse said:
I've fired up my first Visual C++ .NET (Version 7) project and have made
some nice progress. However, I'm now trying to call the familiar
GetWindowsDirectory() API.

When I'm laying in the code, the editor recognizes the function (it is
prompting me for the proper parameters) but when I compile I get "Error
3861: 'GetWindowsDirectory' : identifier not found, even with argument
dependent lookup".
...
Can someone see what I'm doing wrong? It could be a real bone-head
mistake -- I'm new to this development environment.

What kind of project are you building? If you are building a native Windows
application, did you include this line

#include <windows.h>

Regards,
Will
 
H

Harry Whitehouse

Hello Will!

Thanks for getting back on this. My target platform is indeed Windows and I
guess I was a bit surprised when the application building didn't add
windows.h automatically.

I've tried adding that to stdafx.h and, when I did, some new errors popped
up in strange places. In one case a System::MessageBox() line of code was
in error and in another case an icon reference for a button threw a compiler
error. I gave it a try again, and remarked out the problem lines, and now I
get a good compile and link!

This was the icon line that threw an error:

//this->Icon = (__try_cast<System::Drawing::Icon *
(resources->GetObject(S"$this.Icon")));


So is there another way to start a project in VC++ .NET which defines from
the outset that this will be a Windows application?

Thanks!

Harry

..
 
W

William DePalo [MVP VC++]

Harry Whitehouse said:
So is there another way to start a project in VC++ .NET which defines from
the outset that this will be a Windows application?

I was wondering whether you were targetting the .Net framework or native
Windows as <windows.h> is not required in the former case and in fact can be
a little problematic in managed applications.

I start new native projects like this, from the menu File->New then then I
click on the Visual C++ Projects "folder" then I choose the Win32 Project
icon in the right pane then the Application Settings link on the next dialog
and finally I check one of the application types.

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top