nSerialHD with UNC-Notation?

nSerialHD with UNC-Notation?

Postby Dietmar Jahnel » Sun May 20, 2007 3: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
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby James Bott » Mon May 21, 2007 9: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.
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Dietmar Jahnel » 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?
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby James Bott » Tue May 22, 2007 4: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Ken Wantz » Thu May 24, 2007 1: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.

Code: Select all  Expand view
                                    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.
Ken Wantz
 
Posts: 45
Joined: Wed Nov 29, 2006 7:48 pm
Location: Toronto Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 99 guests