FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour nSerialHD with UNC-Notation?
Posts: 83
Joined: Mon Oct 17, 2005 10:33 AM
nSerialHD with UNC-Notation?
Posted: Sun May 20, 2007 03:06 PM

Hi everybody,

We are using the HD serial number for copy protection.
It works fine with mapped network drives.

Now we have a potential customer who requires to start the programm without a mapped drive using the UNC-Notation.

Is there a way to retrieve the serial number of the network drive with for example "\OURPC\TEST" instead of "E:" or similar?

Thank for any hints and help!
Dietmar

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
nSerialHD with UNC-Notation?
Posted: Mon May 21, 2007 09:42 PM

Dietmar,

Below is an old message that may help. I haven't tried it.

Regards,
James


From: "GNR" <gnr@hyderabadwater.gov.in>
Subject: Re: nSerialHd() to work with all drives
Date: Saturday, February 15, 2003 10:04 AM

nSerialID() works well on all drives, mapped and physical.
I have tested this with FiveWin 2.0D and it works perfectly on mapped drives also.

I am reproducing the test program below:

include "fivewin.ch"

////////////////////////
FUNCTION Main( cDrive )

LOCAL nSerial
local cHex

DEFAULT cDrive := "C:"

nSerial := nSerialHD(cDrive)

cHex := L2HEX(nSerial)
cHex := LEFT(cHex,4) + "-" +RIGHT(cHex,4)

MSGINFO(cHex)

RETURN (0)
/////////////////////////
STATIC FUNCTION L2HEX(nDeciNum)

LOCAL cHex := ""

IF nDeciNum < 0
nDeciNum += ( 16 * 256 * 256 * 256 * 256 )
ENDIF

DO WHILE LEN(cHex) < 8
cHex := N16H(nDeciNum % 16) + cHex
nDeciNum := INT(nDeciNum/16)
ENDDO

RETURN ( PADL(cHex,8,"0") )
////////////////////////////
STATIC FUNCTION N16H(N)

IF N < 10
RETURN STR(N,1)
ELSEIF N < 16
N -= 9
RETURN CHR(64+N)
ENDIF

// ERROR

RETURN "*"
//////////////////////////////

This program returns the same result as VOL dos command returns.
Also It gives the same result from any PC in the net work or sthe same PC
The builtin L2HEX function is not good.
I have replaced this function.
I have tested this with FW 2.0d. I do not know how other versions behave.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 83
Joined: Mon Oct 17, 2005 10:33 AM
nSerialHD with UNC-Notation?
Posted: Tue May 22, 2007 11:47 AM

Thanks James,

but this one does not help, cause it requires the drive letter.
We need the serial number of a file-server-HD using the UNC-notation

Anybody?

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
nSerialHD with UNC-Notation?
Posted: Tue May 22, 2007 04:32 PM

Dietmar,

>but this one does not help, cause it requires the drive letter.
>We need the serial number of a file-server-HD using the UNC-notation

Did you try it? It works for me using "\compaq\c"

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 45
Joined: Wed Nov 29, 2006 07:48 PM
nSerialHD with UNC-Notation?
Posted: Thu May 24, 2007 01:53 PM
James,

I tested the code and found that it does not work using UNC and it also has another quirk.

The quirk is if the drive is "C:" it does not work but if I use "C:\" it works. Using either "D:" or "D:\" or higher, both operations work. Why it does not work with the "C" drive may be because I am running the app also from the "C" drive.

I added code to the routine to see just what is happening as well as using the xHarbour function for reading the serial number as well. The comments on the right of the code shows the returned results; first using a UNC (which doesn't exist on my system) as well as a drive letter from my local system.

                                    Bogus UNC         Valid local drive
msginfo(cDrive)                  // \\compaq\C:    -- C:\

msginfo(nSerialHD(cDrive))       // 4524474        -- 1479837593

cHex := L2HEX(nSerialHD(cDrive))
cHex := LEFT(cHex,4) + "-" + RIGHT(cHex,4)
MSGINFO(cHex)                    //0045-09BA       -- 5834-8799

msginfo(VolSerial(cDrive))       // -1             -- 1479837593.000000
cHex := L2HEX(VolSerial(cDrive))
cHex := LEFT(cHex,4) + "-" + RIGHT(cHex,4)
msginfo(cHex)                    // FFFF-FFFF      -- 5834-8799


I also tried using a valid UNC which gave the same result.

In case my understanding is wrong, let me say that I was trying to go from an XP Pro system through a Netgrear router to an XP Home system. I tried all possibilities. "\\Aopen\boot" (the vol name of that particular drive), "\\Aopen\C", "\\Aopen\C:", "\\Aopen\C:\" etc. Every time the same codes were returned. It seems that the FiveWin function returns a bogus value while the xHarbour function retruns -1 if it cannot read the serial number.

Since the VOL command cannot read the serial using UNC notation may be the reason why these 2 functions can't do it either.

Continue the discussion