28.10.2006, 16:40 | #1 |
Участник
|
Fred Shen: Pass complex data types to 3rd party DLLs in Axapta
Источник: http://fredshen.spaces.live.com/Blog...E4E3!163.entry
============== If you are using third-party dll files, you may encounter a problem that you need pass a complex data types to or from the dlls, for example, struct, array etc. There is an example to show you how to pass struct data type to dlls. Below is the api of a given dll. /* C++ API – SampleDll.dll typedef struct { LPCTSTR lpszFontName; int nCharacterExtra; int nFontHigh; int nSpacing; int nAlign; LPCTSTR lpszTextString; } BCTEXTINFO, *LPBCTEXTINFO; BCENCODE_API DWORD WINAPI SampleDllMethod(LPBCTEXTINFO lpTextInfo); */ And we can use Binary class to store the string's address instead of including the string directly in the struct. Here is a sample code to show you how to pass a struct to dll. client static int SampleMethod(str _name, int _chExtra, int _fontHeight, int _spacing, int _align, str _content) { int ret; Binary lpTextInfo = new Binary(24); // 6 * 4 = 24 Binary biName = new Binary(strlen(_name) + 1); Binary biContent = new Binary(strLen(_content) + 1); DLL _winApiDLL = new DLL('SampleDll.dll'); DLLFunction _SampleMethod = new DLLFunction(_winApiDLL,'SampleDllMethod'); ; _ SampleMethod.returns(ExtTypes:: DWord); _ SampleMethod.arg( ExtTypes::Pointer, ExtTypes::Pointer); biName.string(0, _name); biContent.string(0, _content); lpTopTextInfo.binary(0, biName); lpTopTextInfo.dWord(4, _chExtra); lpTopTextInfo.dWord(8, _ fontHeight); lpTopTextInfo.dWord(12, _ spacing); lpTopTextInfo.dWord(16, _ align); lpTopTextInfo.binary(20, biContent); ret = _ SampleMethod.call(lpTextInfo); return ret; } ============== Источник: http://fredshen.spaces.live.com/Blog...E4E3!163.entry |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|