Problems with FFI
"goobamarino" <[email protected]> Mon, 07 Apr 2003 11:47:09 -0000
| Newsgroups | gmane.lisp.corman |
|---|---|
| Message-ID | <[email protected]> |
Win2k (windows 5.0 service pack 1) Corman 2.01 with patches applied.
If I evaluate the code shown below immediately after loading
Cormanlisp and then try to call the function WinBrowseForFiles, it
closes the IDE every time. If I execute other code first and try
WinBrowseForFiles somewhat after loading Cormanlisp, the function
works several time in succession but fails eventually. Any obvious
clues what I am doing wrong?
;;; example for FFI failure
(load (concatenate 'string *cormanlisp-directory*
"modules\\com-type-libs.lisp"))
(in-package :win32)
#!(:export t :library "comdlg32" :pascal "WINAPI")
typedef struct tagOFN {
DWORD lStructSize; //_WIN32_WINNT < 0x0500 use
OPENFILENAME_SIZE_VERSION_400 vice sizeof
HWND hwndOwner;
HINSTANCE hInstance;
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
// these don't exist in _WIN32_WINNT < 0x0500
void * pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
} OPENFILENAME, *LPOPENFILENAME;
// nt 4.0
// _WIN32_WINNT < 0x0500
BOOL WINAPI GetOpenFileNameA(
LPOPENFILENAME lpofn
);
!#
;;;; Function Definitions
;;get a file name (windows 5.0)
(defun WinBrowseForFiles ()
(let ((lpOFN (malloc (sizeof 'LPOPENFILENAME))))
(with-c-struct (strct lpOFN OPENFILENAME)
(setf lStructSize (sizeof 'OPENFILENAME)
hwndOwner cl::c_null
hInstance cl::c_null
lpstrFilter cl::c_null
lpstrCustomFilter cl::c_null
nMaxCustFilter 0
nFilterIndex 0
lpstrFile (malloc (* (sizeof 'LPTSTR) 260))
nMaxFile 260
lpstrFileTitle cl::c_null
nMaxFileTitle 0
lpstrInitialDir cl::c_null
lpstrTitle cl::c_null
Flags 0
nFileOffset 0
nFileExtension 0
lpstrDefExt cl::c_null
lCustData 0
lpfnHook cl::c_null
lpTemplateName cl::c_null
pvReserved cl::c_null
dwReserved 0
FlagsEx 0))
;;; null initialize lpstrFile to suppress garbage in the buffer
(setf (cref LPTSTR (cref OPENFILENAME lpOFN lpstrFile) 0) 0)
(if (getOpenFileName lpOFN)
(c-string-to-lisp-string (cref OPENFILENAME lpOFN
lpstrFile)))))
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/W7NydA/hdqFAA/VygGAA/SyjtlB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
[email protected]
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/