K
kingswang
Unregistered / Unconfirmed
GUEST, unregistred user!
#include "stdafx.h"
#include "List.h"
typedef struct _LISTITEM
{
struct _LISTITEM* pUp;
struct _LISTITEM* pNext;
SONGINFO Info;
}LISTITEM;
typedef struct _LIST
{
S8 Path[ MAX_PATH ];
LISTITEM* pListItem;
}LIST;
//载入以pFilePath为名字的列表文件。
BOOL TListLoad( LIST* pList, S8* pFilePath )
{
CFileFind fileFind;
LISTITEM * p = pList->pListItem;
DWORD ReadNum;
HANDLE file = CreateFile( pFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
//打开文件失败
if( file == INVALID_HANDLE_VALUE )return 0;
char* Data;
unsigned long l = ::GetFileSize( file, NULL );
Data = new char[l+1];
if( !Data ) return 0;
SetFilePointer( file, 0, NULL,FILE_begin
);
ReadFile( file, (LPDWORD)Data, l, &ReadNum, NULL);
//是否需要遍历列表?
strcpy( pList->Path, pFilePath );
while( p ) p = p->pNext;
CloseHandle( file );
return 1;
}
#include "List.h"
typedef struct _LISTITEM
{
struct _LISTITEM* pUp;
struct _LISTITEM* pNext;
SONGINFO Info;
}LISTITEM;
typedef struct _LIST
{
S8 Path[ MAX_PATH ];
LISTITEM* pListItem;
}LIST;
//载入以pFilePath为名字的列表文件。
BOOL TListLoad( LIST* pList, S8* pFilePath )
{
CFileFind fileFind;
LISTITEM * p = pList->pListItem;
DWORD ReadNum;
HANDLE file = CreateFile( pFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
//打开文件失败
if( file == INVALID_HANDLE_VALUE )return 0;
char* Data;
unsigned long l = ::GetFileSize( file, NULL );
Data = new char[l+1];
if( !Data ) return 0;
SetFilePointer( file, 0, NULL,FILE_begin
);
ReadFile( file, (LPDWORD)Data, l, &ReadNum, NULL);
//是否需要遍历列表?
strcpy( pList->Path, pFilePath );
while( p ) p = p->pNext;
CloseHandle( file );
return 1;
}