Using Libref SASCBTBL Windows DLLs can be used within SAS. This works very performantly since Windows 95. But some routines from kernel32.dll do no longer work under Windows 7 x64 whereas kernel32.dll still exist. e.g. FindFirstFileA, FindNextFileA, FindClose. => ERROR: Write Access Violation DATASTEP. Any idea how these routines can be reactivated unter Win 7 64 bit? Below you find an Win x32 working example, which gets the first two entries for C:\*.* Any suggestions are wellcome. Heinrich --------------------- FILENAME SASCBTBL "C:\Temp\DLLAttributeTable.txt"; * Create Attribute Table with the description of the routines; DATA _NULL_; FILE SASCBTBL; INPUT; PUT _INFILE_; CARDS4; * SASCBTBL Attribute Table for Description of external DLLs used by SAS; * DLL used: KERNEL32.DLL; * Routines: FindFirstFileA, FindNextFileA, FindClose; ************************************************* HANDLE FindFirstFile( LPCTSTR lpFileName, // file name LPWIN32_FIND_DATA lpFindFileData // data buffer ); ROUTINE FindFirstFileA minarg=11 maxarg=11 stackpop=called module=Kernel32 returns=long; arg 1 char input format=$CSTR260.; * LPCTSTR lpFileName, // address of name of file to search for ; * LPWIN32_FIND_DATA lpFindFileData // address of returned information ; arg 2 num output fdstart format=pib4.; * DWORD dwFileAttributes ; arg 3 num output format=pib8.; * FILETIME ftCreationTime ; arg 4 num output format=pib8.; * FILETIME ftLastAccessTime ; arg 5 num output format=pib8.; * FILETIME ftLastWriteTime ; arg 6 num output format=pib4.; * DWORD nFileSizeHigh ; arg 7 num output format=pib4.; * DWORD nFileSizeLow ; arg 8 num output format=pib4.; * DWORD dwReserved0 ; arg 9 num output format=pib4.; * DWORD dwReserved1 ; arg 10 char output format=$CSTR260.; * TCHAR cFileName[ MAX_PATH ] ; arg 11 char output format=$CSTR14.; * TCHAR cAlternateFileName[ 14 ] ; ************************************************* BOOL FindNextFile( HANDLE hFindFile, // search handle LPWIN32_FIND_DATA lpFindFileData // data buffer ); ROUTINE FindNextFileA minarg=11 maxarg=11 stackpop=called module=Kernel32 returns=long; arg 1 num input byvalue format=pib4.; * HANDLE hFindFile, // handle of search ; * LPWIN32_FIND_DATA lpFindFileData // address of structure for data on found file; arg 2 num output fdstart format=pib4.; * DWORD dwFileAttributes ; arg 3 num output format=pib8.; * FILETIME ftCreationTime ; arg 4 num output format=pib8.; * FILETIME ftLastAccessTime ; arg 5 num output format=pib8.; * FILETIME ftLastWriteTime ; arg 6 num output format=pib4.; * DWORD nFileSizeHigh ; arg 7 num output format=pib4.; * DWORD nFileSizeLow ; arg 8 num output format=pib4.; * DWORD dwReserved0 ; arg 9 num output format=pib4.; * DWORD dwReserved1 ; arg 10 char output format=$CSTR260.; * TCHAR cFileName[ MAX_PATH ] ; arg 11 char output format=$CSTR14.; * TCHAR cAlternateFileName[ 14 ] ; ************************************************* BOOL FindClose( HANDLE hFindFile // file search handle ); ROUTINE FindClose minarg=1 maxarg=1 stackpop=called module=Kernel32 returns=long; arg 1 num input byvalue format=pib4.; * HANDLE hFindFile // file search handle ; ;;;; RUN; ***************** Usage in Data Step; data dirlist; length Path $256 Name $256 DosName $14 Attributes 8; path="C:\*.*"; handle=modulen ("FindFirstFileA", path, Attributes, created, accessed, written, sizeH, sizeL, reserve0, reserve1, Name, DosName); put _all_; handle=modulen ("FindNextFileA", handle, Attributes, created, accessed, written, sizeH, sizeL, reserve0, reserve1, Name, DosName); put _all_; handle=modulen ("FindClose", handle); put _all_; run;
... View more