AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 28.10.2006, 16:40   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
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
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Fred Shen: Convert Axapta date type value to datetime type value in SQL Server Blog bot DAX Blogs 0 28.10.2006 16:40
Fred Shen: Tips on optimizing primary index in Axapta Blog bot DAX Blogs 0 28.10.2006 16:40
Fred Shen: Development Features of Dynamics Ax (Axapta) 4.0 Blog bot DAX Blogs 0 28.10.2006 16:40
Fred Shen: Use resource files in Axapta Blog bot DAX Blogs 0 28.10.2006 16:40
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 17:05.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.