C/C++¶àÖÖ·½·¨»ñÈ¡Îļþ´óС
#include <iostream>
#include <io.h>
#include <sys\stat.h>
#include <afx.h>
#define _AFXDLL
using namespace std;
void main()
{
// ´ËÎļþÔÚ¹¤³Ì´ò¿ª×´Ì¬ÏÂΪ²»¿É·ÃÎÊ
char* filepath = "..\\test.ncb";
// ·½·¨Ò»
struct _stat info;
_stat(filepath, &info);
int size = info.st_size;
cout<<size<<endl;
// ·½·¨¶þ
FILE* file = fopen(filepath, "rb");
if (file)
{
int size = filelength(fileno(file));
cout<<size<<endl;
fclose(file);
}
// ·½·¨Èý
CFile cfile;
if (cfile.Open(filepath, CFile::modeRead))
{
int size = cfile.GetLength();
cout<<size<<endl;
}
// ·½·¨ËÄ
HANDLE handle = CreateFile(filepath, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle != INVALID_HANDLE_VALUE)
{
int size = GetFileSize(handle, NULL);
cout<<size<<endl;
Close
Ïà¹ØÎĵµ£º
VC.NETÖеÄStringÀàÊÇÀûÓÃUnicode×Ö·û¼¯±àÂëÀ´±íʾÎı¾¡£Unicode×Ö·û¼¯ÖÐÿ¸ö×Ö·û(ºº×Ö¡¢Ó¢ÎÄ×Öĸ)¶¼Õ¼2¸ö×Ö½Ú£¬ÇÒÆä×Ö·û´®ÊÇÒÔ2¸öÁ¬ÐøµÄ\0½áβµÄ¡£
ANSIµÄASCII×Ö·û¼¯ÊÇ×î³£¼ûµÄ×Ö·û¼¯£¬³£ÓÃÓÚ±íʾtxtµÄÎı¾Îļþ¡£ÔÚASCII×Ö·û¼¯ÖÐÓ¢ÎÄÕ¼Ò»¸ö×Ö½Ú£¬ºº×Ö2¸ö×Ö½Ú£¬ÇÒÆä×Ö·û´®ÊÇÒÔÒ»¸ö\0½áβµÄ¡£
ÔÚÀûÓÃVC.NET½øÐлìºÏ±à³Ìʱ ......
µÚÒ»ÖÖÀí½â
±ÈÈç˵ÄãÓÃC++¿ª·¢ÁËÒ»¸öDLL¿â£¬ÎªÁËÄܹ»ÈÃCÓïÑÔÒ²Äܹ»µ÷ÓÃÄãµÄDLLÊä³ö(Export)µÄº¯Êý£¬ÄãÐèÒªÓÃextern "C"À´Ç¿ÖƱàÒëÆ÷²»ÒªÐÞ¸ÄÄãµÄ
º¯ÊýÃû¡£
ͨ³££¬ÔÚCÓïÑÔµÄÍ·ÎļþÖо³£¿ÉÒÔ¿´µ½ÀàËÆÏÂÃæÕâÖÖÐÎʽµÄ´úÂ룺
#ifdef __cplusplus
extern "C" {
#endif
/**** some declaration or so *****/
#ifde ......
Ç°Á½ÌìÔÚÍøÉÏ¿´µ½¡¶Cר¼Ò±à³Ì¡·Õâ±¾ÊéµÄÆÀ¼Û»¹²»´í£¬¾ÍÈ¥ÊéµêÂòÁËÒ»±¾»ØÀ´Åõ¶Á£¬Ã¿ÌìÍíÉÏ¿´Ò»Ð©¡£Ì½ÌÖµÄÎÊÌâȷʵ±È½ÏÉ¶¼ÔÚÌÖÂÛCÓïÑÔ±¾ÉíµÄÎÊÌâÁË¡£Ìáµ½ÁËCÓïÑÔÖеÄһЩ²»×ã¡£±¾À´ÈÏΪCÓïÑÔÊÇÎÞи¿É»÷µÄ£¬¿É´Ó×÷ÕߵĽǶȿ´À´£¬È·ÊµÓÐЩ²»Í׵ĵط½£¬ÏëÏëÒ²ÊÇ£¬ÄÄÓÐÍêÃÀÎÞȱ¶«Î÷ÄØ¡£Æäʵ×÷ÕßÒ²²¢·ÇÔڱᵠ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. parsfnmº¯Êý
parsfnmº¯ÊýµÄ¹¦ÄÜÊÇ·ÖÎöÎļþÃû£¬ÆäÓ÷¨Îª£ºchar *parsfnm (char *cmdline, struct fcb *fcbptr, ......