Newsgroup: it.comp.lang.visual-basic
Titolo: WIN XP chiamata API con esito 0 (sero)

Salve a tutti il Newsgroup
Solitamente frequento it.com.appl.access MA nessuno ha saputo risolvermi il
problemino in questione.
Effetto una chiamata API per avere il numero serie dell'hard-disk su cui è
installato il mio applicativo access.
Ora, se eseguo l'applicativo (che è su un server) da un PC con installato
Win 9x ottengo il risultato richiesto, ovvero il numero di serie dell'HDD,
ma se lo stesso applicativo lo lancio da WIN XP questo ritorna valore 0
(ZERO) !!!!!!!!!!!!!!!!!!!!!!!!
Mi sembra un'asurdità e non capisco come altrimenti risolvere il problema.
Qualcuno sa dirmi xchè ed evetualmente come fare?
Faccio seguito del modulo VB di chiamata API:
----------------------------------------------------------------------------
-
Option Compare Database
Option Explicit
Declare Function wu_GetVolumeInformation Lib "kernel32.dll" Alias
"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal
lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long,
lpVolumeSerialNumber As Double, lpMaximumComponentLength As Long,
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal
nFileSystemNameSize As Long) As Long
Function ap_GetVolumeInformation() As Variant
       Dim lpRootPathName As String * 255
       Dim lpVolumeNameBuffer As String * 255
       Dim nVolumeNameSize As Long
       Dim lpVolumeSerialNumber As Double
       Dim lpMaximumComponentLength As Long
       Dim lpFileSystemFlags As Long
       Dim lpFileSystemNameBuffer As String * 255
       Dim nFileSystemNameSize As Long
       Dim lngLength As Long
       Dim lngResult As Long
       lpRootPathName = "C:\" & lpRootPathName
       lngResult = wu_GetVolumeInformation(lpRootPathName,
lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber,
lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer,
nFileSystemNameSize)
       ap_GetVolumeInformation = lpVolumeSerialNumber
End Function
----------------------------------------------------------------------------
--------
Grazie


Non complicarti la vita:
'Code
Private Declare Function GetVolumeInformation Lib "kernel32.dll" _
    Alias "GetVolumeInformationA" _
    (ByVal lpRootPathName As String, _
    ByVal lpVolumeNameBuffer As String, _
    ByVal nVolumeNameSize As Integer, _
    lpVolumeSerialNumber As Long, _
    lpMaximumComponentLength As Long, _
    lpFileSystemFlags As Long, ByVal _
    lpFileSystemNameBuffer As String, _
    ByVal nFileSystemNameSize As Long) As Long
Function GetSerialNumber(strDrive As String) As Long
    Dim SerialNum As Long
    Dim Res As Long
    Dim Temp1 As String
    Dim Temp2 As String
    Temp1 = String$(255, Chr$(0))
    Temp2 = String$(255, Chr$(0))
    Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), _
        SerialNum, 0, 0, Temp2, Len(Temp2))
    GetSerialNumber = SerialNum
End Function
'End Code
Dovrebbe andare anca su access (o al_cess?) :-)))))
Ciao
--
Timothy Redaelli

 > Effetto una chiamata API per avere il numero serie dell'hard-disk su cui
č


 nel campo maschera
Option Compare Database
Private Declare Function GetVolumeInformation Lib "kernel32.dll" _
    Alias "GetVolumeInformationA" _
    (ByVal lpRootPathName As String, _
    ByVal lpVolumeNameBuffer As String, _
    ByVal nVolumeNameSize As Integer, _
    lpVolumeSerialNumber As Long, _
    lpMaximumComponentLength As Long, _
    lpFileSystemFlags As Long, ByVal _
    lpFileSystemNameBuffer As String, _
    ByVal nFileSystemNameSize As Long) As Long
Function GetSerialNumber(strDrive As String) As Long
    Dim SerialNum As Long
    Dim Res As Long
    Dim Temp1 As String
    Dim Temp2 As String
    Temp1 = String$(255, Chr$(0))
    Temp2 = String$(255, Chr$(0))
    Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), _
        SerialNum, 0, 0, Temp2, Len(Temp2))
    GetSerialNumber = SerialNum
End Function
Sub Main()
    MsgBox GetSerialNumber("c:\")
End Sub
N.B. Copia l'esempio su access e ricorda di mettere "C:\" non "C:"
Ciao
--
Timothy Redaelli


Guarda le piattaforme incriminate: secondo me e' un problema di diritti di
accesso...
Ciaotutti,
*

 ha scritto nel messaggio
news:a3mlv2$19812i$1...@ID-87006.news.dfncis.de...
