注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

gmd20的个人空间

// 编程和生活

 
 
 

日志

 
 

VB.Net的两个用法,久了不用基本语法都忘了  

2010-04-10 20:49:50|  分类: 程序设计 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

VB.Net中的换行用下划线,C中的字符串指针参数,直接声明为byval as string

来自 FindFile Sample http://msdn.microsoft.com/en-us/library/3k3z0k7a(VS.71).aspx

原型:

HANDLE FindFirstFile(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData);

typedef struct _WIN32_FIND_DATA
{
DWORD    dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD    nFileSizeHigh;
DWORD    nFileSizeLow;
DWORD    dwReserved0;
DWORD    dwReserved1;
TCHAR    cFileName[ MAX_PATH ];
TCHAR    cAlternateFileName[ 14 ];
} WIN32_FIND_DATA, *PWIN32_FIND_DATA;

' Declares a class member for each structure element.
< StructLayout( LayoutKind.Sequential, CharSet := CharSet.Auto )> _
Public Class FindData
   Public fileAttributes As Integer = 0
   ' creationTime was a by-value FILETIME structure.
   Public creationTime_lowDateTime As Integer = 0
   Public creationTime_highDateTime As Integer = 0
   ' lastAccessTime was a by-value FILETIME structure.
   Public lastAccessTime_lowDateTime As Integer = 0
   Public lastAccessTime_highDateTime As Integer = 0
   ' lastWriteTime was a by-value FILETIME structure.
   Public lastWriteTime_lowDateTime As Integer = 0
   Public lastWriteTime_highDateTime As Integer = 0
   Public nFileSizeHigh As Integer = 0
   Public nFileSizeLow As Integer = 0
   Public dwReserved0 As Integer = 0
   Public dwReserved1 As Integer = 0
   < MarshalAs( UnmanagedType.ByValTStr, SizeConst := 256 )> _
   Public fileName As String = Nothing
   < MarshalAs( UnmanagedType.ByValTStr, SizeConst := 14 )> _
   Public alternateFileName As String = Nothing
End Class 'FindData

Public Class LibWrap
   ' Declares a managed prototype for the unmanaged function.
   Declare Auto Function FindFirstFile Lib "Kernel32.dll" _
      ( ByVal fileName As String, <[In], Out> ByVal findFileData As _
      FindData ) As IntPtr
End Class 'LibWrap

Public Class App
   Public Shared Sub Main()
  
      Dim fd As New FindData()
      LibWrap.FindFirstFile( "C:\*", fd )
      Console.WriteLine( "The first file: {0}", fd.fileName )
     
   End Sub 'Main
End Class 'App

  评论这张
 
阅读(587)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017