以前写了个获取硬盘序列号的fortran程序,但未经实证
program FortranDemo Use Kernel32 Implicit None Interface SUBROUTINE GetDiskSerialNumber1(drive, pout, poutsize)
!DEC$ ATTRIBUTES STDCALL :: GetDiskSerialNumber1
!DEC$ ATTRIBUTES Alias:'GetDiskSerialNumber1':: GetDiskSerialNumber1
!DEC$ ATTRIBUTES REFERENCE:: pout, poutsize
INTEGER :: poutsize
CHARACTER(len=1) :: drive
CHARACTER :: pout(*)
End SUBROUTINE
SUBROUTINE DoReg(user,userlen,regid,regidlen)
!DEC$ ATTRIBUTES STDCALL :: DoReg
!DEC$ ATTRIBUTES Alias:'DoReg':: DoReg
!DEC$ ATTRIBUTES REFERENCE:: pout, poutsize
INTEGER :: userlen,regidlen
CHARACTER :: user(*),regid(*)
End SUBROUTINE End Interface CHARACTER(len=20) dllname
Logical RetLog
INTEGER poutsize
CHARACTER drive
CHARACTER :: pout(100)
CHARACTER(len=100) :: user
CHARACTER(len=300) :: regid
INTEGER userlen,regidlen
Pointer (fGetDiskSerialNumber1, GetDiskSerialNumber1)
Pointer (fDoReg, DoReg)
!32位下INTEGER(4),64位下INTEGER(8)
!INTEGER(4) hLib
!DEC$ IF DEFINED (_X86_)
INTEGER(4) hLib
dllname="jydisk.DLL"C
print *,'win32'
!DEC$ ELSE
INTEGER(8) hLib
dllname="jydisk64.DLL"C
print *,'win64 '
!DEC$ ENDIF hLib = LoadLibrary(dllname) fDoReg = GetProcAddress(hLib, 'DoReg'C)
print *,'DoReg= ',fDoReg fGetDiskSerialNumber1 = GetProcAddress(hLib, 'GetDiskSerialNumber1'C)
print *,'GetDiskSerialNumber1= ',fGetDiskSerialNumber1 user="[email protected]"
regid="telme"
userlen=len(trim(user))
regidlen=len(trim(regid))
call DoReg(user,userlen, regid,regidlen) drive="c"
PRINT *, 'in= ',drive
call GetDiskSerialNumber1(drive, pout,poutsize)
!print *,'RetLog= ',Retlog PRINT *, 'OUTPUT(1)= ',poutsize
PRINT *, 'OUTPUT(2)= ',pout RetLog = FreeLibrary(hLib) end program FortranDemo