EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Callback File System as console appication

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#6805
Posted: 07/01/2008 11:49:46
by Eugene Mayevski (EldoS Corp.)

Ok... but can the service itself "see" the drive after the drive was added? You can use GetDriveType() API function for this or you can use FindFirst/FindClose to check.

As for local vs global mounting point, this depends solely on your task and your design decision.


Sincerely yours
Eugene Mayevski
#6807
Posted: 07/01/2008 12:46:24
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Yes, the service sees the drive as a DRIVE_REMOVABLE, at least that is the return from GetDeviceType().

I tried the sample code I got from the forum to broadcast the WM_DEVICECHANGE message and I get some sort of unhandled exception in explorer.exe.
#6808
Posted: 07/01/2008 14:36:33
by Volodymyr Zinin (EldoS Corp.)

What version of Windows (including also whether it's 32 or 64-bit) and type of the CallbackFS api (.NET, Delphi, C++) are you using?
Also please specify your code chunk that calls AddMountingPointEx. And does AddMountingPointEx finish successfully?
#6809
Posted: 07/01/2008 14:55:24
by Volodymyr Zinin (EldoS Corp.)

Quote
Sid Schipper wrote:
I still would like to know whether I should add my mounting point as a global or a local mounting point?

It's simpler to use the global mounting points. With them you mustn't worry about logon sessions where mounting points should be created.
#6824
Posted: 07/02/2008 11:50:43
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I am using Windows XP Professional SP1 and the C++ Library interface to CBFS.

Below is my code snippet. Please let me know what I am doing wrong. Thank you.

BTW, how do you get your forum system to indent things nicely, tabs do not seem to work? Also in the code snippet below, the value for UseNetworkMountingPoint is FALSE.

typedef long (WINAPI *BroadcastSystemMessageW_Type)( DWORD, LPDWORD, UINT, WPARAM, LPARAM );


long nRetFromfp = 0;

char * sRegKey = DEFAULT_REG_KEY;
bool bNewRegKey = false;
g_CbFs.SetRegistrationKey(sRegKey);

g_CbFs.SetUseSystemCache(TRUE);

g_CbFs.CreateStorage();

g_CbFs.MountMedia(nTimeoutValue);

if (UseNetworkMountingPoint)
g_CbFs.AddNetworkMountingPoint(_T("S:"), NULL, false, NULL);
else
{
g_CbFs.AddMountingPointEx(_T("S:"), FALSE, NULL);
HMODULE hUser32Dll = LoadLibrary(_T("USER32.DLL"));
WCHAR letter = 'S';
if (hUser32Dll)
{
BroadcastSystemMessageW_Type fp = (BroadcastSystemMessageW_Type)GetProcAddress(hUser32Dll, "BroadcastSystemMessageW");

ASSERT(fp);
if (fp)
{
DWORD dwRecipients;
DEV_BROADCAST_VOLUME dbv;

dbv.dbcv_size = sizeof(dbv);
dbv.dbcv_devicetype = DBT_DEVTYP_VOLUME;
dbv.dbcv_reserved = 0;
dbv.dbcv_unitmask = (1 << letter);
dbv.dbcv_flags = DBTF_NET;

dwRecipients = BSM_APPLICATIONS;
nRetFromfp = fp( BSF_FORCEIFHUNG | BSF_NOHANG | BSF_NOTIMEOUTIFNOTHUNG,
&dwRecipients,
WM_DEVICECHANGE,
(WPARAM)DBT_DEVICEARRIVAL,
(LPARAM)(DEV_BROADCAST_HDR*)&dbv );
}
}
FreeLibrary(hUser32Dll);
CString strDriveRootPath(_T("S:\\"));
UINT dType = GetDriveType(strDriveRootPath);
}


#6860
Posted: 07/07/2008 11:19:14
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I am still waiting for a reply to this thread, are you looking at the code I sent you?
#6862
Posted: 07/07/2008 12:22:27
by Volodymyr Zinin (EldoS Corp.)

Sorry for the delay. I'll answer you in a short time.
#6865
Posted: 07/07/2008 15:21:57
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I just tried an experiment that gave me some curious results that I'd like to tell you about. I ran my VDisk application as a service, but I put in a call to the Windows API function GetLogicalDriveStrings directly after I use your AddMountingPointEX to add the S: drive to the global namespace. I attached to the service process using the Visual C++ debugger and after the call to GetLogicalDriveStrings the S: drive was returned to me as a logical drive.

I then started up another debugging session with a program that I wrote that does only the call to GetLogicalDriveStrings. In that program, the S: drive also is returned to me as a logical drive. But, when I start up an explorer window from the same user where I am running the program that just does the GetLogicalDriveStrings, the drive does not show up?

I then do the Broadcast that you suggested, of the DeviceChanged message and the drive still does not show up in Windows explorer, but does appear in the return from GetLogicalDriveStrings. This seems very curious to me and I am at a loss to explain it. Maybe you can help me?
#6866
Posted: 07/07/2008 15:27:53
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

As a follow-up to my last post, another interesting thing is under the scenario I described above, if I open a cmd DOS command line console window I am able to navigate to my S: drive and use it as I would expect. So, it seems that the only problem I have is that Windows Explorer cannot see my S: drive for some unexplained reason.
#6880
Posted: 07/08/2008 11:30:56
by Volodymyr Zinin (EldoS Corp.)

I've created a nt-service from the Mapper sample and it works well. The sources of it is attached to this message. For writing the service I used the NTService sample described here: http://msdn.microsoft.com/en-us/library/ms810429.aspx
Before starting the service the driver and VSMntNtf.dll helper dll must be installed. The service is installed by specifying the key -i in its command line. After that it can be started/stopped from the "Services" applet in "Administrative tools".

Quote
Sid Schipper wrote:
Below is my code snippet. Please let me know what I am doing wrong. Thank you.
The BroadcastSystemMessage call won't work if the code is called from the system account (i.e. in context of a nt-service). You must call this function from an user session whose Explorer must be notified.


[ Download ]
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 15445 times

Number of guests: 8, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!