FBWF API using C++

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi @ all,

I have to develop an graphical FBWF-Manger application using the
FBWF API. The IDE I´m using is Visual Studio 6.0 using C++.

I want to query all excluded files with the following code but I always get
a Errorcode 87 from function FbwfGetExclusionList. Errorcode 87 means
"invalid parameter" but I can´t find any mistake.
Please look at the code below:

ULONG ulCurrentSession = 1;

WCHAR szDrive[32];
swprintf(szDrive, L"C:\\");

ULONG cbSize = 32;
BYTE *pszExcludedFiles = new BYTE[32];

int iErr = FbwfGetExclusionList(szDrive, ulCurrentSession, pszExcludedFiles,
&cbSize);


Thanks for reply, Chriz
 
Hi @ all,

I have to develop an graphical FBWF-Manger application using the
FBWF API. The IDE I´m using is Visual Studio 6.0 using C++.

I want to query all excluded files with the following code but I always get
a Errorcode 87 from function FbwfGetExclusionList. Errorcode 87 means
"invalid parameter" but I can´t find any mistake.
Please look at the code below:

ULONG ulCurrentSession = 1;

WCHAR szDrive[32];
swprintf(szDrive, L"C:\\");

ULONG cbSize = 32;
BYTE *pszExcludedFiles = new BYTE[32];

int iErr = FbwfGetExclusionList(szDrive, ulCurrentSession, pszExcludedFiles,
&cbSize);

Thanks for reply, Chriz

Chriz,

Take a look at Sean Liming's excellent article on the FBWF API - It
includes (Copyrighted) source code:
http://www.seanliming.com/Docs/FBWF_API.pdf
 
Chriz,

Have you tried to pass in the "C:" instead of the "C:\\" string as the volume name?
It must be either a driver letter (C:) or a device name (\\device\<harddiskvolume>).
 
Hey Guys,

thanks for reply. Now it works.
The Errorcode 87 was confusing me because there´s
an additional returnvalue which should be returned by the
FbwfGetExclusionList()-Function when the drivename is
wrong!?

By the way:
Is it possible to get the drive letter by the function
FbwfGetVolumeList() or rather convert the volume string
into an drive letter?

Greez, Chriz
 
Chriz,
By the way:
Is it possible to get the drive letter by the function
FbwfGetVolumeList() or rather convert the volume string
into an drive letter?

I think FBWF lacks that functionality but you may try EWF API instead: EwfMgrGetDriveLetterFromVolumeName
(http://msdn2.microsoft.com/en-us/library/ms933232.aspx).
This function should not have any dependency on running EWF.

Otherwise just stick to regular Win32 VolumeManager API: GetVolumeNameForVolumeMountPoint, GetVolumePathNamesForVolumeName. (there
is also WMI and SetupDi API that provide similar functionality)
 
Hello,

thanks for your solutions.
I found another API-function: QueryDosDevice()
In use of this function I wrote the following function to
resolve the devicename (volumename) to the driveletter:

CString DeviceNameToDrive(char *szDevice)
{
char szDrives[256];
char szCurDevice[256];
GetLogicalDriveStrings(sizeof(szDrives), szDrives);

int iSubStr = 0;
CString strDrive;

while(AfxExtractSubString(strDrive, szDrives, iSubStr, '\0') &&
strDrive.Compare("") != 0)
{
strDrive.Remove('\\');
QueryDosDevice(strDrive.GetBuffer(0), szCurDevice, 256);

if(strcmp(szDevice, szCurDevice) == 0)
{
strDrive += "\\";
return strDrive;
}

iSubStr++;
}
return "";
}
 
Chriz,

Oops.. I actually sent you the opposite API info :-)
You ended up calling the right API though - QueryDosDevice is what you want to use when you need to convert the volume name to drive
letter. GetVolumeNameForVolumeMountPoint is to be used vice verse.

And keep in mind that you can always parse out the info from the [HKLM\System\MountedDevices] key that is created by the same volume
manager component.

--
=========
Regards,
KM
Hello,

thanks for your solutions.
I found another API-function: QueryDosDevice()
In use of this function I wrote the following function to
resolve the devicename (volumename) to the driveletter:

CString DeviceNameToDrive(char *szDevice)
{
char szDrives[256];
char szCurDevice[256];
GetLogicalDriveStrings(sizeof(szDrives), szDrives);

int iSubStr = 0;
CString strDrive;

while(AfxExtractSubString(strDrive, szDrives, iSubStr, '\0') &&
strDrive.Compare("") != 0)
{
strDrive.Remove('\\');
QueryDosDevice(strDrive.GetBuffer(0), szCurDevice, 256);

if(strcmp(szDevice, szCurDevice) == 0)
{
strDrive += "\\";
return strDrive;
}

iSubStr++;
}
return "";
}

KM said:
Chriz,


I think FBWF lacks that functionality but you may try EWF API instead: EwfMgrGetDriveLetterFromVolumeName
(http://msdn2.microsoft.com/en-us/library/ms933232.aspx).
This function should not have any dependency on running EWF.

Otherwise just stick to regular Win32 VolumeManager API: GetVolumeNameForVolumeMountPoint, GetVolumePathNamesForVolumeName.
(there
is also WMI and SetupDi API that provide similar functionality)
 
Hello KM,

sorry but I think you have overlooked something.
QueryDosDevice() converts the driverletter (e. g. "C:") to the volume name /
device name (e.g. "\device\harddiskvolume1").
GetVolumeNameForVolumeMountPoint() should to the same but on Windows XPe it
returns another path instead of \device\harddiskvolume1 as the FBWF returns.

< What I want it to convert the volumename to the driveletter. >

But it doesn´t matter if I have a function which converts the driveletter to
the volumename or the volumename to the driveletter. The only consequence is
to write a little more code code instead just calling one function.
As in the sourcecode above I used the function QueryDosDevice() and
established the volumenames of all drives. When the volumename of a drive
matches the passed parameter I have found the corresponding driveletter.

Best regards, Chriz
 
Chriz,

Thanks for the clarification.
Looking at the QueryDosDevice description in MSDN I can see where I was wrong. I actually never tried that function on XP and I
should'd gotten to MSDN first and read the docs before the previous post.

The GetVolumeNameForVolumeMountPoint however does work on XPe. At least it did for me a while ago.
The only trick was to use it twice - get the unique volume name by calling the API first and then enumerate all the dos device names
(drive letters) in the system (either from A to Z or by using GetLogicalDrives/GetLogicalDriveStrings) to find the right volume
string.
Now looking at the code you posted it seems like similar approach you've taken but just ended up using different API.

If you happened to have access to DDK, there is another API there: IoVolumeDeviceToDosName, that does what you need. But it may
appear more trouble to link to DDK from your win32 app.

Thanks again for posting your findings.
 
Hey Chriz,

I am trying the same thing like you, developing an FBWF API. Got a few
problems...! Did you get to your goal? Is there a possibility that I can get
the source code from you, just to see how you call all the API-functions.

Would be great.

Greetings Mario
 
Back
Top