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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 28.09.2007, 20:54   #1  
Blog bot is offline
Blog bot
Участник
 
25,493 / 847 (79) +++++++
Регистрация: 28.10.2006
axaptapedia: WinInet class
Источник: http://www.axaptapedia.com/WinInet_class
==============

Summary: Description and Extension of the WinInet class
== What it can do for you ==
This class provides a way to interact with web-pages on the internet.


To save an image from a web-link, you need to add the following method to the [[WinInet]] class:

#winapi
int internetSaveFile(int hdl, str _fileName)
{
Binary _buffer = new Binary(2048);
Binary _bytesRead = new Binary(4);
int cnt = 0;
boolean ret;
DLLFunction fileCreate;
DLLFunction writeFile;
DLL dll = new Dll(@"KERNEL32.DLL");
int hFile;
;
if (_fileName)
{
fileCreate = new DLLFunction(dll, @"CreateFileA");
fileCreate.returns(ExtTypes::DWord);
fileCreate.arg(ExtTypes::String,
ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord,
ExtTypes::DWord);

writeFile = new DllFunction(dll, @"WriteFile");
writeFile.arg(ExtTypes::DWord, ExtTypes::Pointer, ExtTypes::DWord, ExtTypes::Pointer, ExtTypes::DWord);
writeFile.returns(ExtTypes::DWord);

hFile = fileCreate.call(_fileName, #GENERIC_WRITE, 0, 0, #CREATE_ALWAYS, 0, 0);
while (hFile != #INVALID_HANDLE_VALUE)
{
ret = _internetReadFile.call(hdl,_buffer,2000,_bytesRead);
if (ret && _bytesRead.dWord(0))
{
cnt += _bytesRead.dWord(0);
writeFile.call(hFile, _buffer, _bytesRead.dWord(0), _bytesRead, 0);
}
else
break;
}
if (hFile != #INVALID_HANDLE_VALUE)
winapi::closeHandle(hFile);
}
return cnt;
}


Here is a test job showing how it works:

static void internetSaveFile(Args _args)
{
WinInet winInet;
int hdl;
;
winInet = new WinInet();
hdl = winInet.internetOpenUrl("http://www.axforum.info/forums/customavatars/avatar4154_1.gif");
info (strfmt("%1 bytes saved", winInet.internetSaveFile(hdl, "c:\temp\avatar4154_1.gif")));
}


[[Category:Class_development]]


Источник: http://www.axaptapedia.com/WinInet_class
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axaptapedia: RunBaseBatch Blog bot DAX Blogs 0 04.04.2009 22:05
axaptapedia: RunBaseBatch Blog bot DAX Blogs 0 31.03.2009 06:06
axaptapedia: Image class Blog bot DAX Blogs 0 22.07.2008 15:05
axaptapedia: SaxReader class Blog bot DAX Blogs 0 11.09.2007 11:50
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43

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

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

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