头文件怎么定义?

头文件怎么定义?,第1张

#ifndef __ABC_H__

#define __ABC_H__

//以上是为了防止头文件被多次包含,可以省略,最好有,名字任意,保证唯一即可

//以下是宏定义,可有可无

#define MAX 100

#define MIN 0

//以下是结构声明,可有可无

typedef struct{

int a

}ABC

//以下是函数声明,可有可无

void abcfun(int a,int b)

...

#endif

就这么多

给你个VB遍历文件夹的代码吧

Private

Declare

Function

FindFirstFile

Lib

"kernel32"

Alias

"FindFirstFileA"

(ByVal

lpFileName

As

String,

lpFindFileData

As

WIN32_FIND_DATA)

As

Long

'查找下一个文件的API

Private

Declare

Function

FindNextFile

Lib

"kernel32"

Alias

"FindNextFileA"

(ByVal

hFindFile

As

Long,

lpFindFileData

As

WIN32_FIND_DATA)

As

Long

'获取文件属性的API

Private

Declare

Function

GetFileAttributes

Lib

"kernel32"

Alias

"GetFileAttributesA"

(ByVal

lpFileName

As

String)

As

Long

'关闭查找文件的API

Private

Declare

Function

FindClose

Lib

"kernel32"

(ByVal

hFindFile

As

Long)

As

Long

Const

MAX_PATH

=

260

Const

MAXDWORD

=

&HFFFF

Const

FILE_ATTRIBUTE_DIRECTORY

=

&H10

Private

Type

FILETIME

dwLowDateTime

As

Long

dwHighDateTime

As

Long

End

Type

Dim

tempstr

As

String

'定义类(用于查找文件)

Private

Type

WIN32_FIND_DATA

dwFileAttributes

As

Long

ftCreationTime

As

FILETIME

ftLastACCESSTime

As

FILETIME

ftLastWriteTime

As

FILETIME

nFileSizeHigh

As

Long

nFileSizeLow

As

Long

dwReserved0

As

Long

dwReserved1

As

Long

cFileName

As

String

*

MAX_PATH

cAlternate

As

String

*

14

End

Type

Dim

filecount

As

Integer

Dim

dirs()

As

String

Dim

curr

As

Long

Dim

ss()

As

String

Private

Sub

Command1_Click()

tempstr

=

"c:"

searchdir

tempstr

filecount

=

0

End

Sub

Public

Function

searchdir(path

As

String)

Dim

WFD

As

WIN32_FIND_DATA

Dim

i

As

Long

Dim

temp

As

String

Dim

h

As

Long

Dim

zhaodao

As

Long

Dim

iindex

As

Integer

Dim

dirs()

As

String

Dim

l

As

Long

zhaodao

=

1

h

=

FindFirstFile(path

&

"\*.*",

WFD)

If

h

<>

-1

Then

While

zhaodao

zhaodao

=

1

temp

=

Left(WFD.cFileName,

InStr(WFD.cFileName,

Chr$(0))

-

1)

If

temp

<>

"."

And

temp

<>

".."

Then

If

WFD.dwFileAttributes

And

vbDirectory

Then

ReDim

Preserve

dirs(iindex)

dirs(iindex)

=

path

&

"\"

&

temp

iindex

=

iindex

+

1

ReDim

Preserve

ss(filecount)

ss(filecount)

=

path

&

"\"

&

temp

filecount

=

filecount

+

1

End

If

End

If

zhaodao

=

FindNextFile(h,

WFD)

Wend

End

If

FindClose

(h)

If

iindex

>

0

Then

For

i

=

0

To

iindex

-

1

Call

searchdir(dirs(i))

Next

i

End

If

End

Function

SetFileTime

VB声明

Declare Function SetFileTime Lib "kernel32" Alias "SetFileTime" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME,lpLastWriteTime As FILETIME) As Long

说明

设置文件的创建、访问及上次修改时间

返回值

Long,非零表示成功,零表示失败。会设置GetLastError

参数表

参数 类型及说明

hFile Long,系统文件句柄

lpCreationTime FILETIME,文件的创建时间

lpLastAccessTime FILETIME,文件上一次访问的时间

lpLastWriteTime FILETIME,文件最近一次修改的时间

GetFileTime

VB声明

Declare Function GetFileTime Lib "kernel32" Alias "GetFileTime" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME,lpLastWriteTime As FILETIME) As Long

说明

取得指定文件的时间信息

返回值

Long,非零表示成功,零表示失败。会设置GetLastError

参数表

参数 类型及说明

hFile Long,文件的句柄

lpCreationTime FILETIME,用于装载文件的创建时间

lpLastAccessTime FILETIME,用于装载文件上一次访问的时间(FAT文件系统不支持 这一特性)

lpLastWriteTime FILETIME,用于装载文件上一次修改的时间

注解

如果不需要特定的信息,那么lpCreationTime,lpLastAccessTime,lpLastWriteTime 都可以设置为零(用ByVal As Long)。这个函数返回的文件时间采用UTC格式


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12061972.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存