﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Релиб / Программирование / .NET / VB.NET  / Срочно - стринги и вызов Win32 API функций / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Релиб</description><link>http://www.relib.com/forums/</link><webMaster>robot@relib.com</webMaster><lastBuildDate>Sun, 23 Nov 2008 02:42:16 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Срочно - стринги и вызов Win32 API функций</title><link>http://www.relib.com/forums/Topic895601-27-1.aspx</link><description>Ответ на первоначальный вопрос найден с помощью Messir-a.&lt;P&gt;[quote]&lt;/P&gt;&lt;P&gt;Declare Function FtpFindFirstFile Lib "wininet.dll" _&lt;BR&gt;   (ByVal hConnect As IntPtr, ByVal searchFile As String, _&lt;BR&gt;   ByRef findFileData As WIN32_FIND_DATA, ByVal flags As Integer, _&lt;BR&gt;   ByVal context As IntPtr) As IntPtr&lt;BR&gt;&lt;/P&gt;&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&amp;lt;Serializable(), StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)&amp;gt; _&lt;BR&gt;    Structure WIN32_FIND_DATA&lt;BR&gt;    Public dwFileAttributes As FileAttributes&lt;BR&gt;    Public ftCreationTime As FILETIME&lt;BR&gt;    Public ftLastAccessTime As FILETIME&lt;BR&gt;    Public ftLastWriteTime As FILETIME&lt;BR&gt;    Public nFileSizeHigh As Integer&lt;BR&gt;    Public nFileSizeLow As Integer&lt;BR&gt;    Public dwReserved0 As Integer&lt;BR&gt;    Public dwReserved1 As Integer&lt;BR&gt;    &amp;lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)&amp;gt; _&lt;BR&gt;      Public cFileName As String&lt;BR&gt;    &amp;lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)&amp;gt; _&lt;BR&gt;        Public cAlternate As String&lt;BR&gt;    End Structure&lt;BR&gt;&lt;/P&gt;&lt;P&gt;[/quote]&lt;/P&gt;&lt;P&gt;Ключевыми словами тут является декларирование стринга в структуре с маршализацией и указанием точного типа и размера стринга.</description><pubDate>Wed, 10 May 2006 12:00:06 GMT</pubDate><dc:creator>kpoxa</dc:creator></item><item><title>RE: Срочно - стринги и вызов Win32 API функций</title><link>http://www.relib.com/forums/Topic895601-27-1.aspx</link><description>В принципе ты прав. Но для того, в том числе, и создавался дотнет чтобы избежать использования вызовов API (за исключением выдающихся случаев).Насчет как передать команду ///MSDNThe Method property determines which command is sent to the server. Typically, you set Method by using the strings defined in the WebRequestMethods.Ftp structure. When setting Method to UploadFile, you must do so before calling the GetRequestStream method. Failure to call these members in the correct order causes a ProtocolViolationException exception when you attempt to get the request stream.The credentials supplied for the FtpWebRequest object must have permission to perform the specified method. If not, the FTP command fails.You can set Method to any command recognized by the server and use the FtpWebRequest object to send the command. This works as expected only if the command does not require you to send data and the server does not send data in response to the request. You must not send any command that alters the state of the connection. For example, do not use the "MODE", "PASV", or "PORT" commands. Using commands that change the state of the connection can leave the request and the underlying connection in an unusable state. To determine the success or failure of a command, check the Status and StatusDescription properties.Может тебе стоит внимательно почитать там и разобрать предложенные примеры - в 90% случаев помогает.И еще, где то на сайте MSDN валяется архив 101 VB.Net samples.Скачай и знакомься с особенностями языка.Работу с сетевыми потоками можно посмотреть в примереAdvanced .NET Framework (Networking) - Use SocketsА в нем клиентскую часть.Кстати, если ты четко понимаешь что и как передавать -  можешь использовать его впрямую, просто поменяй открываемые порты (там используется 80(HTTP)).Надеюсь, что помог.</description><pubDate>Fri, 21 Apr 2006 17:11:00 GMT</pubDate><dc:creator>Serge_OK</dc:creator></item><item><title>RE: Срочно - стринги и вызов Win32 API функций</title><link>http://www.relib.com/forums/Topic895601-27-1.aspx</link><description>Это очень хорошо, что есть встроенная поддержка FTP, но:1. Так как .Net не заменяет все функции WinAPI, то если не в этот раз, то в другой, я снова столкнусь с необходимостью получения инфы от виндов через структуры в которых могут быть стринги, и как мне их все же создавать и передавать?2. Из просмотра топиков "How to: Download Files with FTP" и т.д. я не понял, а как мне передавать [bold]команды[/bold] например такую "siteside blksize 3096"? Мне необходимо подключаться через FTP к Mainfraim-у. А у него есть особые команды.Хочу заметить, что приведенные топики дают примеры исползования на C#, а я его не знаю, да и VB.NET для меня тоже пока в новинку.</description><pubDate>Thu, 20 Apr 2006 18:46:00 GMT</pubDate><dc:creator>kpoxa</dc:creator></item><item><title>RE: Срочно - стринги и вызов Win32 API функций</title><link>http://www.relib.com/forums/Topic895601-27-1.aspx</link><description>А зачем через API? дот-нет имеет встроенные cредства доступа к FTP/// MSDNThe .NET Framework provides comprehensive support for the FTP protocol with the FtpWebRequest and FtpWebResponse classes. These classes are derived from WebRequest and WebResponse. In most cases, the WebRequest and WebResponse classes provide all that is necessary to make the request, but if you need access to the FTP-specific features exposed as properties, you can typecast these classes to FtpWebRequest or FtpWebResponse.ExamplesFor more information, see the following topics: How to: Download Files with FTP, How to: Upload Files with FTP, and How to: List Directory Contents with FTP.</description><pubDate>Thu, 20 Apr 2006 16:52:00 GMT</pubDate><dc:creator>Serge_OK</dc:creator></item><item><title>Срочно - стринги и вызов Win32 API функций</title><link>http://www.relib.com/forums/Topic895601-27-1.aspx</link><description>Я новичек в VB.NET.В VB6 можно было декларировать стринг как[code]Dim strDirectory as String * 256[/code]и потом передать в API функцию декларированную как[code]Private Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" ( _                                ByVal hConnect As Integer, ByRef sCurrentDirectory As String, _                                ByRef dwCurrentDirectory As Integer) As Boolean[/code] после чего вызов выглядит как[code]FtpGetCurrentDirectory(hConnect, strDirectory, dwDirLen )[/code]Теперь же, в .NET декларация функции выглядит так[code]Private Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" ( _                                ByVal hConnect As Integer, ByVal sCurrentDirectory As System.Text.StringBuilder, _                                ByRef dwCurrentDirectory As Integer) As Boolean[/code]а вызов так[code]Dim strPath As String, dwCount As Integer = 1024, bRes As BooleanDim strBuilder As New System.Text.StringBuilder(dwCount)   If (Connected) Then       bRes = _FtpGetCurrentDirectory(m_hSession, strBuilder, dwCount)       If (bRes = False) Then           strPath = Nothing       Else           strPath = strBuilder.ToString()       End If   Else       strPath = Nothing   End If[/code]Это более запутанно, но еще понятно. Но в следующем случае я не понимаю как мне декларировать структуру, чтобы вызов API был правильным:[code]Private Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" ( _                                ByVal hConnect As Integer, ByVal sSearchFile As String, _                                ByRef findFileData As WIN32_FIND_DATA, ByVal dwFlags As Integer, _                                ByVal dwContext As Integer) As Integer    Private Structure WIN32_FIND_DATA        Dim dwFileAttributes As Integer        Dim ftCreationTime As System.Runtime.InteropServices.ComTypes.FILETIME        Dim ftLastAccessTime As System.Runtime.InteropServices.ComTypes.FILETIME        Dim ftLastWriteTime As System.Runtime.InteropServices.ComTypes.FILETIME        Dim nFileSizeHigh As Integer        Dim nFileSizeLow As Integer        Dim dwReserved0 As Integer        Dim dwReserved1 As Integer        &lt;VBFixedString(256)&gt; Dim cFileName As String        &lt;VBFixedString(14)&gt; Dim cAlternateFileName As String    End Structure...   Dim winFileData As WIN32_FIND_DATA, strFileName As String = Nothing   Dim hDirConnect As Integer   hDirConnect = FtpFindFirstFile(m_hSession, "", winFileData, 0, 0)      &lt;--- Здесь происходит ексепшион[/code]Как я понял, проблема в декларации стрингов в структуре. Я пробовал декларировать их и как обычный стринг, и какSystem.Text.StringBuilder, но ничего не помогает. (тип ошибок при различных декларациях разный, но результат тот же).Вопрос: как в .NET декларируются структуры со стрингами для последующей передачи их в Win32 API функции для заполнения полей?</description><pubDate>Thu, 20 Apr 2006 13:58:00 GMT</pubDate><dc:creator>kpoxa</dc:creator></item></channel></rss>