?
Solved

How to compile 32 bit app that uses Wow64DisableWow64FsRedirection with BDS 2006

Posted on 2009-05-19
8
Medium Priority
?
1,403 Views
Last Modified: 2013-11-17
Hello, I'm trying to compile my 32 bit application written with the C plus plus builder personality of BDS 2006.

The problem is that I need to use the API function Wow64DisableWow64FsRedirection. MSDN states that _WIN32_WINNT must be defined to 0x0501 or higher, but if I do such definition, the compiler gives me the following error:

[C++ Error] Windows.hpp(2435): E2040 Declaration terminated incorrectly

This error is related to this definition:

static const Shortint WTS_CONSOLE_CONNECT = 0x1;

Many errors like this follows the first. I cannot understand why the compiler gives me the error. If I avoid to redefine _WIN32_WINNT everything compiles except the point where I use the needed function.

Any ideas?

Thanks in advance.
0
Comment
Question by:uuderzo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
8 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 24433795
You can circumvent that by loading 'Wow64DisableWow64FsRedirection()' dynamically from kernel32.dll, e.g.
typedef BOOL WINAPI (*FPTR_Wow64DisableWow64FsRedirection)(PVOID*);
typedef BOOL WINAPI (*FPTR_Wow64RevertWow64FsRedirection)(PVOID);
 
// ...
 
PVOID pOldValue;
 
FPTR_Wow64DisableWow64FsRedirection pWow64DisableWow64FsRedirection = GetProcAddress(GetModuleHandle(_T("kernel32.dll"),_T("Wow64DisableWow64FsRedirection"));
FPTR_Wow64RevertWow64FsRedirection pWow64RevertWow64FsRedirection = GetProcAddress(GetModuleHandle(_T("kernel32.dll"),_T("Wow64RevertWow64FsRedirection"));
 
(*pWow64DisableWow64FsRedirection)(&pOldValue);
 
// do stuff
 
(*pWow64RevertWow64FsRedirection)(pOldValue);

Open in new window

0
 

Author Comment

by:uuderzo
ID: 24435690
Wow! That works!
Thank you very much for your solution!

But... just to know... is there a reason of this malfunction? Is it the compiler or the header file?

Thanks again!
0
 

Author Closing Comment

by:uuderzo
ID: 31582955
I'd never tought to this approach. Nice one, even if I still wonder why the compiler gives me that error.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 24435719
Not sure about Borland compilers - if you really want to find ut why that happens, have the preprocessor expand the whole header set and have a look at the lines before that specific error.
0
 
LVL 86

Expert Comment

by:jkr
ID: 24437610
Hum, as a closing word - that should be
typedef BOOL WINAPI (*FPTR_Wow64DisableWow64FsRedirection)(PVOID*);
typedef BOOL WINAPI (*FPTR_Wow64RevertWow64FsRedirection)(PVOID);
 
// ...
 
PVOID pOldValue;
 
FPTR_Wow64DisableWow64FsRedirection pWow64DisableWow64FsRedirection =
(FPTR_Wow64DisableWow64FsRedirection)GetProcAddress(GetModuleHandle(_T("kernel32.dll"),_T("Wow64DisableWow64FsRedirection"));
FPTR_Wow64RevertWow64FsRedirection pWow64RevertWow64FsRedirection = 
(FPTR_Wow64RevertWow64FsRedirection)GetProcAddress(GetModuleHandle(_T("kernel32.dll"),_T("Wow64RevertWow64FsRedirection"));
 
(*pWow64DisableWow64FsRedirection)(&pOldValue);
 
// do stuff
 
(*pWow64RevertWow64FsRedirection)(pOldValue);

Open in new window

0
 

Author Comment

by:uuderzo
ID: 24440310
You're right, the typecast was missing in your answer.
No matter, I managed to make it working.

Thank you for your correction.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question