Code:
'Q178605 #Compile Exe Option Explicit #Include "win32api.inc" Type LARGE_INTEGER lowpart As Dword highpart As Long End Type Declare Function StgOpenStorage Lib "OLE32.DLL" Alias "StgOpenStorage"( _ ByVal pwcsName As String _ , pstgPriority As Dword _ , ByVal grfMode As Dword _ , ByVal snbExclude As Dword _ , ByVal dwreserved As Dword _ , ppstgOpen As Dword _ ) As Long Declare Function ComCall0( ByVal pUnk As Dword ) As Long Declare Function ComCall1( ByVal pUnk As Dword, ByVal p1 As Long ) As Long Declare Function ComCall2( ByVal pUnk As Dword, ByVal p1 As Long, ByVal p2 As Long ) As Long Declare Function ComCall3( ByVal pUnk As Dword, ByVal p1 As Long, ByVal p2 As Long, ByVal p3 As Long ) As Long Declare Function ComCall4( ByVal pUnk As Dword, ByVal p1 As Long, ByVal p2 As Long, ByVal p3 As Long, ByVal p4 As Long ) As Long Declare Function ComCall5( ByVal pUnk As Dword, ByVal p1 As Long, ByVal p2 As Long, ByVal p3 As Long, ByVal p4 As Long, ByVal p5 As Long ) As Long Declare Function IStream_Seek( ByVal pUnk As Dword, ByVal p1 As LARGE_INTEGER, ByVal p2 As Long, p3 As LARGE_INTEGER ) As Long %STREAM_SEEK_SET = 0 Function WinMain( ByVal hCurInstance As Long, _ ByVal hPrevInstance As Long, _ lpszCmdLine As Asciiz Ptr, _ ByVal nCmdShow As Long ) As Long Dim a As Long Dim hr As Long Dim pIStorage As Dword Ptr Dim pIStream As Dword Ptr Dim pcbWritten As Dword Dim pwcsName As String Dim sData As String Dim szwFileName As String Dim newPos As LARGE_INTEGER Dim dwbytesRead As Dword Dim rupBuild As Integer Dim rupYear As Integer Dim liOff As LARGE_INTEGER CoInitialize ByVal 0& szwFileName = UCode$( "c:\windows\desktop\Book1.xls" ) hr = StgOpenStorage( _ szwFileName _ , ByVal 0& _ , %STGM_READ Or %STGM_SHARE_EXCLUSIVE _ , ByVal 0& _ , ByVal 0& _ , pIStorage _ ) If hr = %S_OK Then pwcsName = UCode$( "Workbook" ) Call Dword @@pIStorage[4] Using ComCall5( _ pIStorage _ , StrPtr( pwcsName ) _ , 0 _ , %STGM_READ Or %STGM_SHARE_EXCLUSIVE _ , 0 _ , VarPtr( pIStream ) _ ) To hr If hr <> %S_OK Then pwcsName = UCode$( "Book" ) Call Dword @@pIStorage[4] Using ComCall5( _ pIStorage _ , StrPtr( pwcsName ) _ , 0 _ , %STGM_READ Or %STGM_SHARE_EXCLUSIVE _ , 0 _ , VarPtr( pIStream ) _ ) To hr End If If hr = %S_OK Then liOff.lowpart = 8 liOff.highpart = 0 Call Dword @@pIStream[5] Using IStream_Seek( _ pIStream _ , liOff _ , %STREAM_SEEK_SET _ , newPos _ ) To hr Call Dword @@pIStream[3] Using ComCall3( _ pIStream _ , VarPtr( rupBuild ) _ , SizeOf( rupBuild ) _ , VarPtr( dwbytesRead ) _ ) To hr Call Dword @@pIStream[3] Using ComCall3( _ pIStream _ , VarPtr( rupYear ) _ , SizeOf( rupYear ) _ , VarPtr( dwbytesRead ) _ ) To hr MsgBox "rupBuild " & Str$( rupBuild ) & ", rupYear " & Str$( rupYear ) Call Dword @@pIStream[2] Using ComCall0( pIStream ) End If Call Dword @@pIStorage[2] Using ComCall0( pIStorage ) End If CoUninitialize Function = 1 End Function
http://www.hellobasic.com