Trouble with GetCurrentDirectory/SetCurrentDirectory

Shade

New member
Joined
Mar 28, 2003
Messages
1
I am writing a plug-in to another program in the form of a dll with VC++ .NET. Because I didnt want to have to start the host program every time I changed something, I developed the GUI part of the plug-in separately as a console-application. Now when I moved my GUI back to the dll I get compile errors with GetCurrentDirectory and SetCurrentDirectory and I have no idea why.

Code-snippets:
Code:
String* path = Directory::GetCurrentDirectory();
Directory::SetCurrentDirectory(myPath);

My compile errors:
Code:
error C2039: GetCurrentDirectoryA : is not a member of System::IO::Directory
        D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of System::IO::Directory
error C2660: GetCurrentDirectoryA : function does not take 0 parameters
error C2039: SetCurrentDirectoryA : is not a member of System::IO::Directory
        D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of System::IO::Directory
error C2664: SetCurrentDirectoryA : cannot convert parameter 1 from System::String __gc * to LPCSTR
        Cannot convert a managed type to an unmanaged type

If anyone could tell me why this happens I would be ever grateful. Other System::IO::Directory functions seem to work.
 
Okay, this is evil.

What happened is that you have included an (unmanaged) windows header file that has a macro defined like this
#define SetCurrentDirectory(...) SetCurrentDirectoryA()

The same thing happens with calls to MessageBox. The solution is to undef the macros:

#undef MessageBox
#undef SetCurrentDirectory


Shade said:
I am writing a plug-in to another program in the form of a dll with VC++ .NET. Because I didnt want to have to start the host program every time I changed something, I developed the GUI part of the plug-in separately as a console-application. Now when I moved my GUI back to the dll I get compile errors with GetCurrentDirectory and SetCurrentDirectory and I have no idea why.

Code-snippets:
Code:
String* path = Directory::GetCurrentDirectory();
Directory::SetCurrentDirectory(myPath);

My compile errors:
Code:
error C2039: GetCurrentDirectoryA : is not a member of System::IO::Directory
        D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of System::IO::Directory
error C2660: GetCurrentDirectoryA : function does not take 0 parameters
error C2039: SetCurrentDirectoryA : is not a member of System::IO::Directory
        D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of System::IO::Directory
error C2664: SetCurrentDirectoryA : cannot convert parameter 1 from System::String __gc * to LPCSTR
        Cannot convert a managed type to an unmanaged type

If anyone could tell me why this happens I would be ever grateful. Other System::IO::Directory functions seem to work.
 

Similar threads

M
Replies
0
Views
829
MyCatAlex
M
A
Replies
0
Views
411
AngryBinary
A
C
Replies
0
Views
183
Csaba Árpádházy-Godó
C
L
Replies
0
Views
75
lfvoydfv
L
Back
Top