Comment travailler avec Win32
Bonjour,
Je débute avec Visual C++ 2005 Express Edition
et un problème se pose à moi :
Je souhaite travailler avec l'api win32
et notament :
CreateFile, MapViewOfFile ...
Le problème que j'ai c'est que à la compilation,
j'ai des erreur qui viennent du fait que win32 n'est pas "incluse"
j'ai tout essayé :
#include <win32> avec ou sans .h
#include <windows.h> ne fonctionne pas non plus.
Aucun de ces ficheirs n'existe.
Je ne sais pas si je suis claire, mais que dois-je faire pour travailler avec win32 ?
Edit : Voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h> // Bibliothèque C
using namespace std;
using namespace System;
unsigned long creerGrosFichier(string cheminFichier)
{
unsigned long totalEcrit=0;
fstream grosFichier(cheminFichier.c_str(),fstream::out);
/*for(unsigned long i=0;i<1000000000/sizeof(unsigned long);i++)
{
grosFichier<<i;
totalEcrit += sizeof(unsigned long);
}*/
grosFichier.close();
return totalEcrit;
}
int main(int argc, char * argv[])
{
//***********************************************
// Préparer un gros fichier pour tavailler dessus
//***********************************************
string cheminFichier="G:\\GrosFichier.oct";
fstream grosFichier(cheminFichier.c_str(),fstream::in); // Ouverture en lecture du fichier
if(!grosFichier.is_open())
{
cout<<"[INFO] Le gros fichier n'existe pas."<<endl;
cout<<"[INFO] Creation du gros fichier"<<endl;
unsigned long retourTotalEcrit = creerGrosFichier(cheminFichier);
cout<<"[ ok ] Fin de la creation du gros fichier : "<<retourTotalEcrit<<" octets ecrits."<<sizeof(unsigned long)<<endl;
}
else
{
grosFichier.close();
cout<<"[ OK ] Le gros fichier existe."<<endl;
}
//*************************************************
// Mapper le fichier en mémoire
//*************************************************
HANDLE grosFichierHandler;
grosFichierHandler = CreateFile(cheminFichier,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
return 0;
} |
C'est vraiment un test ! je tiens à le préciser :lol:
Citation:
main.cpp
.\main.cpp(9) : error C2871: 'System' : a namespace with this name does not exist
.\main.cpp(50) : error C2065: 'HANDLE' : undeclared identifier
.\main.cpp(50) : error C2146: syntax error : missing ';' before identifier 'grosFichierHandler'
.\main.cpp(50) : error C2065: 'grosFichierHandler' : undeclared identifier
.\main.cpp(51) : error C2065: 'GENERIC_READ' : undeclared identifier
.\main.cpp(51) : error C2065: 'GENERIC_WRITE' : undeclared identifier
.\main.cpp(51) : error C2065: 'FILE_SHARE_READ' : undeclared identifier
.\main.cpp(51) : error C2065: 'OPEN_EXISTING' : undeclared identifier
.\main.cpp(51) : error C2065: 'FILE_ATTRIBUTE_NORMAL' : undeclared identifier
.\main.cpp(51) : error C3861: 'CreateFile': identifier not found
Ce sont les erreur de compilation.
Merci d'avance...