Из последнего сидакса:
X++:
container internetCrackUrl(str _url, boolean _decode=false, boolean _escape=false)
{
// typedef struct {
// DWORD dwStructSize; 0
// LPTSTR lpszScheme; 4
// DWORD dwSchemeLength; 8
// INTERNET_SCHEME nScheme; 12
// LPTSTR lpszHostName; 16
// DWORD dwHostNameLength; 20
// INTERNET_PORT nPort; 24
// LPTSTR lpszUserName; 28
// DWORD dwUserNameLength; 32
// LPTSTR lpszPassword; 36
// DWORD dwPasswordLength; 40
// LPTSTR lpszUrlPath; 44
// DWORD dwUrlPathLength; 48
// LPTSTR lpszExtraInfo; 52
// DWORD dwExtraInfoLength; 56
// } URL_COMPONENTS, 60
//
// *LPURL_COMPONENTS;
int maxLen = strLen(_url)+1;
DLL dll = new DLL('wininet.dll');
DLLFunction function = new DLLFunction(dll, 'InternetCrackUrlA');
Binary result = new Binary(60);
Binary cnt = new Binary(4);
int ret;
#define.E_POINTER(0x80004003)
// LPTSTR lpszScheme; 4
Binary scheme = new Binary(maxLen);
// LPTSTR lpszHostName; 24
Binary hostName = new Binary(maxLen);
// LPTSTR lpszUserName; 36
Binary userName = new Binary(maxLen);
// LPTSTR lpszPassword; 44
Binary password = new Binary(maxLen);
// LPTSTR lpszUrlPath; 52
Binary urlPath = new Binary(maxLen);
// LPTSTR lpszExtraInfo; 60
Binary extraInfo = new Binary(maxLen);
;
// BOOL InternetCrackUrl(
// LPCTSTR lpszUrl,
// DWORD dwUrlLength,
// DWORD dwFlags,
// LPURL_COMPONENTS lpUrlComponents
// );
// DWORD dwStructSize; 0
result.dWord(0, 60);
// LPTSTR lpszScheme; 4
result.binary(4, scheme);
// DWORD dwSchemeLength; 8
result.dWord(8, maxLen);
// INTERNET_SCHEME nScheme; 12
// LPTSTR lpszHostName; 16
result.binary(16, hostName);
// DWORD dwHostNameLength; 20
result.dWord(20, maxLen);
// INTERNET_PORT nPort; 24
// LPTSTR lpszUserName; 28
result.binary(28, userName);
// DWORD dwUserNameLength; 32
result.dWord(32, maxLen);
// LPTSTR lpszPassword; 36
result.binary(36, password);
// DWORD dwPasswordLength; 40
result.dWord(40, maxLen);
// LPTSTR lpszUrlPath; 44
result.binary(44, urlPath);
// DWORD dwUrlPathLength; 48
result.dWord(48, maxLen);
// LPTSTR lpszExtraInfo; 52
result.binary(52, extraInfo);
// DWORD dwExtraInfoLength; 56
result.dWord(56, maxLen);
function.arg(ExtTypes::String, ExtTypes::DWord, ExtTypes::DWord, ExtTypes::Pointer);
function.returns(ExtTypes::DWord);
ret = function.call(_url, strlen(_url), (_decode ? 0x10000000 : 0) + (_escape ? 0x080000000: 0), result);
if (!ret)
throw error(WinApi::formatMessage(WinApi::getLastError()));
return [scheme.string(0), hostName.string(0), result.dWord(24), userName.string(0), password.string(0), urlPath.string(0), extrainfo.string(0)];
}