Précédent   Forum des professionnels en informatique > C et C++ > Outils pour C & C++ > Visual C++ > VC++ .NET
VC++ .NET Visual C++ pour .NET et Visual C++ Express
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
Vieux 24/06/2008, 12h14   #1
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
Par défaut error LNK2028, error LNK2019

Salut,
Je suis avec VStutio 2005 en C++ sur un projet windows Form.

J'ai récupéré une classe qui permet de lire ou d'écrire dans un fichier EXCEL.
Je l'ai testé dans un autre projet (projet console win32, toujour en c++) et elle marche trés bien pas de problème.

Par contre si je l'ajoute à mon projet windows form la j'ai plein d'erreur de lien.

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
 
1>------ Début de la génération*: Projet*: suivi_horizon, Configuration*: Debug Win32 ------
1>Compilation en cours...
1>excel.cpp
1>.\excel.cpp(139) : warning C4793: 'vararg'*: entraîne la génération de code natif pour la fonction 'HRESULT AutoWrap(int,VARIANT *,IDispatch *,LPOLESTR,int,...)'
1>        .\excel.cpp(36)*: voir la déclaration de 'AutoWrap'
1>.\excel.cpp(158) : warning C4996: 'sprintf' a été déclaré désapprouvé
1>        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345)*: voir la déclaration de 'sprintf'
1>        Message*: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\excel.cpp(162) : warning C4996: 'sprintf' a été déclaré désapprouvé
1>        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345)*: voir la déclaration de 'sprintf'
1>        Message*: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>Édition des liens en cours...
1>excel.obj : error LNK2028: jeton non résolu (0A000031) "extern "C" long __stdcall VariantChangeType(struct tagVARIANT *,struct tagVARIANT *,unsigned short,unsigned short)" (?VariantChangeType@@$$J216YGJPAUtagVARIANT@@0GG@Z) référencé dans la fonction "public: bool __thiscall MyExcel::GetData(char *,char *)" (?GetData@MyExcel@@$$FQAE_NPAD0@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000034) "extern "C" void __stdcall VariantInit(struct tagVARIANT *)" (?VariantInit@@$$J14YGXPAUtagVARIANT@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::ShowGrid(bool)" (?ShowGrid@MyExcel@@$$FQAE_N_N@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000035) "extern "C" void __stdcall SysFreeString(wchar_t *)" (?SysFreeString@@$$J14YGXPA_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000037) "extern "C" wchar_t * __stdcall SysAllocString(wchar_t const *)" (?SysAllocString@@$$J14YGPA_WPB_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000039) "extern "C" long __stdcall GetActiveObject(struct _GUID const &,void *,struct IUnknown * *)" (?GetActiveObject@@$$J212YGJABU_GUID@@PAXPAPAUIUnknown@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::RecupExcel(void)" (?RecupExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003A) "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) référencé dans la fonction "public: bool __thiscall MyExcel::RecupExcel(void)" (?RecupExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003C) "extern "C" long __stdcall CoCreateInstance(struct _GUID const &,struct IUnknown *,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance@@$$J220YGJABU_GUID@@PAUIUnknown@@K0PAPAX@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003D) "extern "C" long __stdcall CLSIDFromProgID(wchar_t const *,struct _GUID *)" (?CLSIDFromProgID@@$$J18YGJPB_WPAU_GUID@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003E) "extern "C" long __stdcall VariantClear(struct tagVARIANT *)" (?VariantClear@@$$J14YGJPAUtagVARIANT@@@Z) référencé dans la fonction "private: void __thiscall MyExcel::Release(void)" (?Release@MyExcel@@$$FAAEXXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003F) "extern "C" void __stdcall CoUninitialize(void)" (?CoUninitialize@@$$J10YGXXZ) référencé dans la fonction "public: __thiscall MyExcel::~MyExcel(void)" (??1MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2028: jeton non résolu (0A000040) "extern "C" long __stdcall CoInitialize(void *)" (?CoInitialize@@$$J14YGJPAX@Z) référencé dans la fonction "public: __thiscall MyExcel::MyExcel(void)" (??0MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2028: jeton non résolu (0A000044) "extern "C" unsigned int __stdcall SysStringLen(wchar_t *)" (?SysStringLen@@$$J14YGIPA_W@Z) référencé dans la fonction "void __cdecl BSTRtoASC(wchar_t *,char * &)" (?BSTRtoASC@@$$FYAXPA_WAAPAD@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000056) "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) référencé dans la fonction "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PB_W1I@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000058) "extern "C" long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) référencé dans la fonction "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) référencé dans la fonction "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) référencé dans la fonction "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PB_W1I@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" unsigned int __stdcall SysStringLen(wchar_t *)" (?SysStringLen@@$$J14YGIPA_W@Z) référencé dans la fonction "void __cdecl BSTRtoASC(wchar_t *,char * &)" (?BSTRtoASC@@$$FYAXPA_WAAPAD@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CoInitialize(void *)" (?CoInitialize@@$$J14YGJPAX@Z) référencé dans la fonction "public: __thiscall MyExcel::MyExcel(void)" (??0MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall VariantClear(struct tagVARIANT *)" (?VariantClear@@$$J14YGJPAUtagVARIANT@@@Z) référencé dans la fonction "private: void __thiscall MyExcel::Release(void)" (?Release@MyExcel@@$$FAAEXXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CoCreateInstance(struct _GUID const &,struct IUnknown *,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance@@$$J220YGJABU_GUID@@PAUIUnknown@@K0PAPAX@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CLSIDFromProgID(wchar_t const *,struct _GUID *)" (?CLSIDFromProgID@@$$J18YGJPB_WPAU_GUID@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall GetActiveObject(struct _GUID const &,void *,struct IUnknown * *)" (?GetActiveObject@@$$J212YGJABU_GUID@@PAXPAPAUIUnknown@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::RecupExcel(void)" (?RecupExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) référencé dans la fonction "public: bool __thiscall MyExcel::RecupExcel(void)" (?RecupExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" void __stdcall SysFreeString(wchar_t *)" (?SysFreeString@@$$J14YGXPA_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" wchar_t * __stdcall SysAllocString(wchar_t const *)" (?SysAllocString@@$$J14YGPA_WPB_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" void __stdcall VariantInit(struct tagVARIANT *)" (?VariantInit@@$$J14YGXPAUtagVARIANT@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::ShowGrid(bool)" (?ShowGrid@MyExcel@@$$FQAE_N_N@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall VariantChangeType(struct tagVARIANT *,struct tagVARIANT *,unsigned short,unsigned short)" (?VariantChangeType@@$$J216YGJPAUtagVARIANT@@0GG@Z) référencé dans la fonction "public: bool __thiscall MyExcel::GetData(char *,char *)" (?GetData@MyExcel@@$$FQAE_NPAD0@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" void __stdcall CoUninitialize(void)" (?CoUninitialize@@$$J10YGXXZ) référencé dans la fonction "public: __thiscall MyExcel::~MyExcel(void)" (??1MyExcel@@$$FQAE@XZ)
1>C:\Documents and Settings\b.ducasse\Bureau\suivi_horizon\Debug\suivi_horizon.exe : fatal error LNK1120: 28 externes non résolus
1>Le journal de génération a été enregistré à l'emplacement "file://c:\Documents and Settings\b.ducasse\Bureau\suivi_horizon\suivi_horizon\Debug\BuildLog.htm"
1>suivi_horizon - 29 erreur(s), 3 avertissement(s)
========== Génération*: 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========

Tous ce que j'ai pu trouvé c'est mettre :
Code :
#pragma comment(lib, "User32.lib")
dans excel .h sa enlève quelques erreurs mais je ne sais pas koi faire d'autre ...

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
 
1>------ Début de la génération*: Projet*: suivi_horizon, Configuration*: Debug Win32 ------
1>Compilation en cours...
1>excel.cpp
1>.\excel.cpp(140) : warning C4793: 'vararg'*: entraîne la génération de code natif pour la fonction 'HRESULT AutoWrap(int,VARIANT *,IDispatch *,LPOLESTR,int,...)'
1>        .\excel.cpp(37)*: voir la déclaration de 'AutoWrap'
1>.\excel.cpp(159) : warning C4996: 'sprintf' a été déclaré désapprouvé
1>        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345)*: voir la déclaration de 'sprintf'
1>        Message*: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\excel.cpp(163) : warning C4996: 'sprintf' a été déclaré désapprouvé
1>        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345)*: voir la déclaration de 'sprintf'
1>        Message*: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>Édition des liens en cours...
1>excel.obj : error LNK2028: jeton non résolu (0A000031) "extern "C" long __stdcall VariantChangeType(struct tagVARIANT *,struct tagVARIANT *,unsigned short,unsigned short)" (?VariantChangeType@@$$J216YGJPAUtagVARIANT@@0GG@Z) référencé dans la fonction "public: bool __thiscall MyExcel::GetData(char *,char *)" (?GetData@MyExcel@@$$FQAE_NPAD0@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000034) "extern "C" void __stdcall VariantInit(struct tagVARIANT *)" (?VariantInit@@$$J14YGXPAUtagVARIANT@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::ShowGrid(bool)" (?ShowGrid@MyExcel@@$$FQAE_N_N@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000035) "extern "C" void __stdcall SysFreeString(wchar_t *)" (?SysFreeString@@$$J14YGXPA_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000037) "extern "C" wchar_t * __stdcall SysAllocString(wchar_t const *)" (?SysAllocString@@$$J14YGPA_WPB_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2028: jeton non résolu (0A000039) "extern "C" long __stdcall GetActiveObject(struct _GUID const &,void *,struct IUnknown * *)" (?GetActiveObject@@$$J212YGJABU_GUID@@PAXPAPAUIUnknown@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::RecupExcel(void)" (?RecupExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003C) "extern "C" long __stdcall CoCreateInstance(struct _GUID const &,struct IUnknown *,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance@@$$J220YGJABU_GUID@@PAUIUnknown@@K0PAPAX@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003D) "extern "C" long __stdcall CLSIDFromProgID(wchar_t const *,struct _GUID *)" (?CLSIDFromProgID@@$$J18YGJPB_WPAU_GUID@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003E) "extern "C" long __stdcall VariantClear(struct tagVARIANT *)" (?VariantClear@@$$J14YGJPAUtagVARIANT@@@Z) référencé dans la fonction "private: void __thiscall MyExcel::Release(void)" (?Release@MyExcel@@$$FAAEXXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003F) "extern "C" void __stdcall CoUninitialize(void)" (?CoUninitialize@@$$J10YGXXZ) référencé dans la fonction "public: __thiscall MyExcel::~MyExcel(void)" (??1MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2028: jeton non résolu (0A000040) "extern "C" long __stdcall CoInitialize(void *)" (?CoInitialize@@$$J14YGJPAX@Z) référencé dans la fonction "public: __thiscall MyExcel::MyExcel(void)" (??0MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2028: jeton non résolu (0A000044) "extern "C" unsigned int __stdcall SysStringLen(wchar_t *)" (?SysStringLen@@$$J14YGIPA_W@Z) référencé dans la fonction "void __cdecl BSTRtoASC(wchar_t *,char * &)" (?BSTRtoASC@@$$FYAXPA_WAAPAD@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" unsigned int __stdcall SysStringLen(wchar_t *)" (?SysStringLen@@$$J14YGIPA_W@Z) référencé dans la fonction "void __cdecl BSTRtoASC(wchar_t *,char * &)" (?BSTRtoASC@@$$FYAXPA_WAAPAD@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CoInitialize(void *)" (?CoInitialize@@$$J14YGJPAX@Z) référencé dans la fonction "public: __thiscall MyExcel::MyExcel(void)" (??0MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall VariantClear(struct tagVARIANT *)" (?VariantClear@@$$J14YGJPAUtagVARIANT@@@Z) référencé dans la fonction "private: void __thiscall MyExcel::Release(void)" (?Release@MyExcel@@$$FAAEXXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CoCreateInstance(struct _GUID const &,struct IUnknown *,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance@@$$J220YGJABU_GUID@@PAUIUnknown@@K0PAPAX@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CLSIDFromProgID(wchar_t const *,struct _GUID *)" (?CLSIDFromProgID@@$$J18YGJPB_WPAU_GUID@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall GetActiveObject(struct _GUID const &,void *,struct IUnknown * *)" (?GetActiveObject@@$$J212YGJABU_GUID@@PAXPAPAUIUnknown@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::RecupExcel(void)" (?RecupExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" void __stdcall SysFreeString(wchar_t *)" (?SysFreeString@@$$J14YGXPA_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" wchar_t * __stdcall SysAllocString(wchar_t const *)" (?SysAllocString@@$$J14YGPA_WPB_W@Z) référencé dans la fonction "public: bool __thiscall MyExcel::Open(char *)" (?Open@MyExcel@@$$FQAE_NPAD@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" void __stdcall VariantInit(struct tagVARIANT *)" (?VariantInit@@$$J14YGXPAUtagVARIANT@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::ShowGrid(bool)" (?ShowGrid@MyExcel@@$$FQAE_N_N@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall VariantChangeType(struct tagVARIANT *,struct tagVARIANT *,unsigned short,unsigned short)" (?VariantChangeType@@$$J216YGJPAUtagVARIANT@@0GG@Z) référencé dans la fonction "public: bool __thiscall MyExcel::GetData(char *,char *)" (?GetData@MyExcel@@$$FQAE_NPAD0@Z)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" void __stdcall CoUninitialize(void)" (?CoUninitialize@@$$J10YGXXZ) référencé dans la fonction "public: __thiscall MyExcel::~MyExcel(void)" (??1MyExcel@@$$FQAE@XZ)
1>C:\Documents and Settings\b.ducasse\Bureau\suivi_horizon\Debug\suivi_horizon.exe : fatal error LNK1120: 22 externes non résolus
1>Le journal de génération a été enregistré à l'emplacement "file://c:\Documents and Settings\b.ducasse\Bureau\suivi_horizon\suivi_horizon\Debug\BuildLog.htm"
1>suivi_horizon - 23 erreur(s), 3 avertissement(s)
========== Génération*: 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 12h54   #2
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Homme
Développeur informatique
Inscription : septembre 2005
Messages : 21 338
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 28
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : septembre 2005
Messages : 21 338
Points : 28 440
Points : 28 440
Envoyer un message via MSN à Médinoc
ole32.lib et oleaut32.lib
__________________
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone.
-- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Médinoc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 13h42   #3
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
merci medinoc mais il quand même 9 erreurs de lien
Une idée ?


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
1>------ Début de la génération*: Projet*: suivi_horizon, Configuration*: Debug Win32 ------
1>Compilation en cours...
1>excel.cpp
1>.\excel.cpp(141) : warning C4793: 'vararg'*: entraîne la génération de code natif pour la fonction 'HRESULT AutoWrap(int,VARIANT *,IDispatch *,LPOLESTR,int,...)'
1>        .\excel.cpp(38)*: voir la déclaration de 'AutoWrap'
1>.\excel.cpp(160) : warning C4996: 'sprintf' a été déclaré désapprouvé
1>        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345)*: voir la déclaration de 'sprintf'
1>        Message*: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\excel.cpp(164) : warning C4996: 'sprintf' a été déclaré désapprouvé
1>        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345)*: voir la déclaration de 'sprintf'
1>        Message*: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>Édition des liens en cours...
1>excel.obj : error LNK2028: jeton non résolu (0A00003C) "extern "C" long __stdcall CoCreateInstance(struct _GUID const &,struct IUnknown *,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance@@$$J220YGJABU_GUID@@PAUIUnknown@@K0PAPAX@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003D) "extern "C" long __stdcall CLSIDFromProgID(wchar_t const *,struct _GUID *)" (?CLSIDFromProgID@@$$J18YGJPB_WPAU_GUID@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2028: jeton non résolu (0A00003F) "extern "C" void __stdcall CoUninitialize(void)" (?CoUninitialize@@$$J10YGXXZ) référencé dans la fonction "public: __thiscall MyExcel::~MyExcel(void)" (??1MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2028: jeton non résolu (0A000040) "extern "C" long __stdcall CoInitialize(void *)" (?CoInitialize@@$$J14YGJPAX@Z) référencé dans la fonction "public: __thiscall MyExcel::MyExcel(void)" (??0MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CoInitialize(void *)" (?CoInitialize@@$$J14YGJPAX@Z) référencé dans la fonction "public: __thiscall MyExcel::MyExcel(void)" (??0MyExcel@@$$FQAE@XZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CoCreateInstance(struct _GUID const &,struct IUnknown *,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance@@$$J220YGJABU_GUID@@PAUIUnknown@@K0PAPAX@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" long __stdcall CLSIDFromProgID(wchar_t const *,struct _GUID *)" (?CLSIDFromProgID@@$$J18YGJPB_WPAU_GUID@@@Z) référencé dans la fonction "public: bool __thiscall MyExcel::NewExcel(void)" (?NewExcel@MyExcel@@$$FQAE_NXZ)
1>excel.obj : error LNK2019: symbole externe non résolu "extern "C" void __stdcall CoUninitialize(void)" (?CoUninitialize@@$$J10YGXXZ) référencé dans la fonction "public: __thiscall MyExcel::~MyExcel(void)" (??1MyExcel@@$$FQAE@XZ)
1>C:\Documents and Settings\b.ducasse\Bureau\suivi_horizon\Debug\suivi_horizon.exe : fatal error LNK1120: 8 externes non résolus
1>Le journal de génération a été enregistré à l'emplacement "file://c:\Documents and Settings\b.ducasse\Bureau\suivi_horizon\suivi_horizon\Debug\BuildLog.htm"
1>suivi_horizon - 9 erreur(s), 3 avertissement(s)
========== Génération*: 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 13h55   #4
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
bon j'ai rajouté des biblis un peux au hazard jusqu'à ce que je tombe sur la dernière qu'il me fallait donc :
Code :
1
2
3
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "oleaut32.lib")
#pragma comment(lib, "ole32.lib")

Mais je me demande quand même pourquoi il ne vas les chercher de lui même ces librairies même si j'imagine que sa a avoir avec le .net
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 15h17   #5
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
Bon en fait le problèmes persiste !
J'avais passé le projet en "Prise en charge du Common Language Runtime (/Clr)" pour passer 4 erreurs mais j'ai besoin de le laisser par default en "Prise en charge du Common Language Runtime MSIL(/Clr:pure)" sinon j'arrive pas à ajouter une source de données à partir d'un objet (rien s'affiche), donc si vous connaissez la dernière bibli a ajouter pour se débarrasser de ces erreurs :
Code :
1
2
3
4
5
6
1>Édition des liens en cours...
1>excel.obj : error LNK2020: jeton non résolu (0A000015) IID_IDispatch
1>excel.obj : error LNK2020: jeton non résolu (0A000024) GUID_NULL
1>excel.obj : error LNK2001: symbole externe non résolu GUID_NULL
1>excel.obj : error LNK2001: symbole externe non résolu IID_IDispatch
1>C:\Documents and Settings\b.ducasse\Bureau\4850\Debug\4850.exe : fatal error LNK1120: 4 externes non résolus
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 15h54   #6
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
Bon je trouve rien à ajouter dans le code le problème vien de la :

Code :
1
2
3
4
5
  if (FAILED(CoCreateInstance(clsExcelApp, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&xlApp.pdispVal))) 
  {
	MessageBox(NULL, L"Excel not registered properly", L"Error", 0x10010);
	return false;
  }
et de la :
Code :
r2=pUnk->QueryInterface(IID_IDispatch, (void **)&xlApp.pdispVal);
Peut être pourrait-on remplacer IID_IDispatch par autre chose ...
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 16h36   #7
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
ou alors comment faire pour ajouter une source de donné objet quand on utilise la "Prise en charge du Common Language Runtime (/Clr)" ...
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 18h37   #8
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Homme
Développeur informatique
Inscription : septembre 2005
Messages : 21 338
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 28
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : septembre 2005
Messages : 21 338
Points : 28 440
Points : 28 440
Envoyer un message via MSN à Médinoc
Rajoute un #include <initguid.h> AVANT les autres includes dans L'UN de tes fichiers sources.
__________________
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone.
-- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Médinoc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 22h10   #9
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
Bien aprés avoir fait ce que tu dit j'ai cette erreur

Code :
'GUID_NULL'*: identificateur non déclaré
peut être que l'on progresse ... ou pas...
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 23h10   #10
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
est ce qu'il n'y a pas moyen de compiler une partie de mes fichier en clr et l'autre partie en clr:pure ou alors de creer deux projet dans une solution en les faisant marcher ensemble
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 23h44   #11
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
si tu veux essayer chez toi

excel.h :
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
54
55
56
57
58
59
60
61
#pragma once
 
#include <windows.h>
 
class MyExcel
{
	public:
		//constructeur
		MyExcel();
		//destructeur
		~MyExcel();
		//Variables
 
		//fonction
		bool NewExcel(void);//lance une nouvelle instance de excel
		bool RecupExcel(void);//recupere une instance de excel
 
		bool IsExcelRunning(void);
		bool SetVisible(bool);//affiche ou non excel
 
		bool AddWorkbook(void);//ajoute un carnet
		bool GetWorkbook(int);//ne marche pas
 
		bool AddWorksheet(void);//ajoute une feuille
		bool GetWorksheet(int);//selectionne une feuille
		bool SetWoksheetName(char *);//change le nom d'une feuille
 
		bool Protect(char* pass);//protge la feuille
		bool UnProtect(char* pass);//deprotege la feuille
 
		bool GetData(char* pPos, char* pData);//lit une valeur dans une cellule
		bool SetData(char* pPos, char* pData);//ecrit une valeur dans une cellule
 
		bool CopyDataRange(char* pPos1, char* pPos2);//copie une zone dans une autre zone
 
		bool RunMacro(char *);//ne marche pas
		bool ShowGrid(bool b);//affiche ou pas la grille
		bool SetPic(char* file);//insere une image
 
		bool SelectRange(char* pPos);//selectionne une zone
 
		bool SetFont(char *font,bool bold, bool under,int size);//applique des modes a un texte
		bool SetColor(long c1,long c2);//change la couleur du texte et du fond d'une cellule
 
		bool ResizeCell(char* nPos);//ne marche pas
 
		bool Open(char* file);//ouvre un fichier
		bool SetSave(bool b);//empeche le message de confirmation
		bool Save(void);//sauvegarde
		bool SaveAs(char* file);//sauvegarde
 
		bool Close(void);//ferme la feuille
		bool Quit(void);//quitte excel
 
	private:
		//variables
 
		//fonctions
		void Release(void);
 
};
excel.cpp :
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
//*************************************************************************************************************************************************************
//									AUTOMATION de EXCEL
//*************************************************************************************************************************************************************
#pragma once
#include <initguid.h>
 
#include <windows.h>
#include <ole2.h>
#include <stdio.h>
#include "excel.h"
 
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "oleaut32.lib")
#pragma comment(lib, "ole32.lib")
 
#define _WIN32_WINNT 0x0501
#define _WIN32_IE 0x0501
 
#define DISP_FREEARGS 0x01
#define DISP_NOSHOWEXCEPTIONS 0x02
 
VARIANT xlApp = {0};//excel.exe
VARIANT xlBooks = {0}; // collection de carnet
VARIANT xlBook = {0}; // 1 carnet
VARIANT xlSheet = {0}; //1 feuille
VARIANT strVariant = {0};
VARIANT lgVariant = {0};
VARIANT cellValue = {0};//valeur
VARIANT cellRange = {0};//selection
VARIANT arr = {0} ; //tableau
VARIANT xlFont = {0}; // police
 
//*****************************************************************************************
//*								Fonctions Speciale
//*****************************************************************************************
/**
 * @brief Automation helper function
 */
HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...)
{
    // Begin variable-argument list...
    va_list marker;
    va_start(marker, cArgs);
 
    if(!pDisp)
    {
        MessageBox(NULL, L"NULL IDispatch passed to AutoWrap()", L"Error", 0x10010);
        _exit(0);
    }
 
    // Variables used...
    DISPPARAMS dp = { NULL, NULL, 0, 0 };
    DISPID dispidNamed = DISPID_PROPERTYPUT;
    DISPID dispID;
    HRESULT hr;
    char buf[200];
    char szName[200];
 
    // Convert down to ANSI
    WideCharToMultiByte(CP_ACP, 0, ptName, -1, szName, 256, NULL, NULL);
 
    // Get DISPID for name passed...
 
 
	IID sa; 
    hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
    if(FAILED(hr))
    {
        sprintf_s(buf, "IDispatch::GetIDsOfNames(\"%s\") failed w/err 0x%08lx", szName, hr);
		MessageBox(NULL,(LPCWSTR)buf, L"AutoWrap()", 0x10010);
        //_exit(0);
        return hr;
    }
 
    // Allocate memory for arguments...
    VARIANT *pArgs = new VARIANT[cArgs+1];
    // Extract arguments...
    for(int i=0; i<cArgs; i++)
    {
        pArgs[i] = va_arg(marker, VARIANT);
    }
 
    // Build DISPPARAMS
    dp.cArgs = cArgs;
    dp.rgvarg = pArgs;
 
    // Handle special-case for property-puts!
    if(autoType & DISPATCH_PROPERTYPUT)
    {
        dp.cNamedArgs = 1;
        dp.rgdispidNamedArgs = &dispidNamed;
    }
 
    // Make the call!
    hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, NULL, NULL);
    if(FAILED(hr))
    {
		sprintf_s(buf, "IDispatch::Invoke(\"%s\"=%08lx) failed w/err 0x%08lx",szName, dispID, hr);
		MessageBox(NULL, (LPCWSTR)buf, L"AutoWrap()", 0x10010);
		switch(hr)
		{
			case DISP_E_BADPARAMCOUNT:
				MessageBox(NULL, L"DISP_E_BADPARAMCOUNT", L"Error:", 0x10010);
				break;
			case DISP_E_BADVARTYPE:
				MessageBox(NULL, L"DISP_E_BADVARTYPE", L"Error:", 0x10010);
				break;
			case DISP_E_EXCEPTION:
				MessageBox(NULL, L"DISP_E_EXCEPTION", L"Error:", 0x10010);
				break;
			case DISP_E_MEMBERNOTFOUND:
				MessageBox(NULL, L"DISP_E_MEMBERNOTFOUND", L"Error:", 0x10010);
				break;
			case DISP_E_NONAMEDARGS:
				MessageBox(NULL, L"DISP_E_NONAMEDARGS", L"Error:", 0x10010);
				break;
			case DISP_E_OVERFLOW:
				MessageBox(NULL, L"DISP_E_OVERFLOW", L"Error:", 0x10010);
				break;
			case DISP_E_PARAMNOTFOUND:
				MessageBox(NULL, L"DISP_E_PARAMNOTFOUND", L"Error:", 0x10010);
				break;
			case DISP_E_TYPEMISMATCH:
				MessageBox(NULL, L"DISP_E_TYPEMISMATCH", L"Error:", 0x10010);
				break;
			case DISP_E_UNKNOWNINTERFACE:
				MessageBox(NULL, L"DISP_E_UNKNOWNINTERFACE", L"Error:", 0x10010);
				break;
			case DISP_E_UNKNOWNLCID:
				MessageBox(NULL, L"DISP_E_UNKNOWNLCID", L"Error:", 0x10010);
				break;
			case DISP_E_PARAMNOTOPTIONAL:
				MessageBox(NULL, L"DISP_E_PARAMNOTOPTIONAL", L"Error:", 0x10010);
				break;
		}
        // _exit(0);
        return hr;
    }
    // End variable-argument section...
    va_end(marker);
 
    delete [] pArgs;
 
    return hr;
}
 
//conversion BSTR to CHAR
void BSTRtoASC (BSTR str, char * &strRet) 
{
	if ( str != NULL ) 
	{
		unsigned long length = WideCharToMultiByte (CP_ACP,0, str,SysStringLen(str), NULL, 0,NULL, NULL	);
		//strRet = new char[length];
		length = WideCharToMultiByte (CP_ACP,0, str,SysStringLen(str), reinterpret_cast <char *>(strRet), length,NULL, NULL	);
		strRet[length] = '\0';
	}
}
 
//translating row and column number into the string name of the cell.
void IndToStr(int row,int col,char* strResult) 
{
	if(col>26) 
	{
          sprintf(strResult,"%c%c%d\0",'A'+(col-1)/26-1,'A'+(col-1)%26,row);
    }
	else 
	{
		sprintf(strResult,"%c%d\0",'A'+(col-1)%26,row);
    }
}
 
//**********************************************************************************
//										La classe
//**********************************************************************************
 
MyExcel::MyExcel() 
{
	// Initialize COM for this thread...
	CoInitialize(NULL);
}
 
MyExcel::~MyExcel() 
{
	//relesase
	Release();
 
   // Uninitialize COM for this thread...
   CoUninitialize();
} 
 
void MyExcel::Release(void) 
{	
	VariantClear(&xlApp);
	VariantClear(&xlBooks);
	VariantClear(&xlBook);
	VariantClear(&xlSheet);
	VariantClear(&cellValue);
	VariantClear(&lgVariant);
	VariantClear(&cellRange);
	VariantClear(&arr);
	VariantClear(&xlFont);
}
 
bool MyExcel::NewExcel(void)
{
  CLSID clsExcelApp;
 
  // if Excel is already running, return with current instance
  if (xlApp.pdispVal != NULL) return true;
 
  /* Obtain the CLSID that identifies EXCEL.APPLICATION
   * This value is universally unique to Excel versions 5 and up, and
   * is used by OLE to identify which server to start.  We are obtaining
   * the CLSID from the ProgID.
   */
   if(FAILED(CLSIDFromProgID(L"Excel.Application", &clsExcelApp))) 
   {
      MessageBox(NULL, L"CLSIDFromProgID() failed", L"Error", 0x10010);
      return false;
   }
 
  // start a new copy of Excel, grab the IDispatch interface
  if (FAILED(CoCreateInstance(clsExcelApp, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&xlApp.pdispVal))) 
  {
	MessageBox(NULL, L"Excel not registered properly", L"Error", 0x10010);
	return false;
  }
 
	// recupere la liste des carnets
	AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &xlBooks, xlApp.pdispVal, L"Workbooks", 0);
 
   return true;
}
 
bool MyExcel::RecupExcel(void)
{
  CLSID clsExcelApp;
 
  // if Excel is already running, return with current instance
  if (xlApp.pdispVal != NULL) return true;
 
  /* Obtain the CLSID that identifies EXCEL.APPLICATION
   * This value is universally unique to Excel versions 5 and up, and
   * is used by OLE to identify which server to start.  We are obtaining
   * the CLSID from the ProgID.
   */
   if(FAILED(CLSIDFromProgID(L"Excel.Application", &clsExcelApp))) 
   {
      MessageBox(NULL, L"CLSIDFromProgID() failed", L"Error", 0x10010);
      return false;
   }
 
   IUnknown *pUnk;
   HWND hExcelMainWnd = 0;
   hExcelMainWnd = FindWindow(L"XLMAIN",NULL);
   if(hExcelMainWnd) 
   {
	   SendMessage(hExcelMainWnd,WM_USER + 18, 0, 0);
		HRESULT hr2 = GetActiveObject(clsExcelApp,NULL,(IUnknown**)&pUnk);
		if (!FAILED(hr2)) 
		{
			hr2=pUnk->QueryInterface(IID_IDispatch, (void **)&xlApp.pdispVal);
			if (!xlApp.ppdispVal) 
			{
				MessageBox(NULL, L"Failed to find instance!!", L"Error",MB_ICONHAND);
				return false;
			}
		}
		//Release the no-longer-needed IUnknown...
		if (pUnk) pUnk->Release();
	}
	else 
	{
		MessageBox(NULL, L"Failed to find instance!!", L"Error",MB_ICONHAND);
		return false;
	}
 
	// recupere la liste des carnets
	AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &xlBooks, xlApp.pdispVal, L"Workbooks", 0);
 
	return true;
}
 
bool MyExcel::Quit(void) 
{
  AutoWrap(DISPATCH_METHOD, NULL, xlApp.pdispVal, L"Quit", 0);
  return true;
}
 
bool MyExcel::Close(void) 
{
  AutoWrap(DISPATCH_METHOD, NULL, xlSheet.pdispVal, L"Close", 0);
  return true;
}
 
bool MyExcel::Save(void) 
{
	AutoWrap(DISPATCH_METHOD, NULL, xlApp.pdispVal, L"Save", 0);
	return true;
}
 
bool MyExcel::SaveAs(char *file)
{
    if( file == NULL) 
	{
        MessageBox(NULL, L"Nom du fichier manquant", L"Error", 0x10010);
        return false;
    }
 
	WCHAR str[MAX_PATH];
	MultiByteToWideChar(CP_ACP, 0,file, -1, str, MAX_PATH);
 
    VARIANT vaPath;
    vaPath.vt = VT_BSTR;
    vaPath.bstrVal = SysAllocString(str);
 
//	VARIANT fformat;
//	fformat.vt = VT_I4;
//	fformat.lVal=-4143;
 
    AutoWrap(DISPATCH_METHOD, NULL, xlBook.pdispVal, L"SaveAs", 1, vaPath);
 
    SysFreeString(vaPath.bstrVal);
	VariantClear(&vaPath);
 
	SetSave(true);
 
	return true;
}
 
bool MyExcel::Open(char *file) 
{
    if( file == NULL) 
	{
        MessageBox(NULL, L"file name is null", L"Error", 0x10010);
        return false;
    }
 
	WCHAR str[MAX_PATH];
	MultiByteToWideChar(CP_ACP, 0,file, -1, str, MAX_PATH);
 
    VARIANT vaPath;
    vaPath.vt = VT_BSTR;
    vaPath.bstrVal = SysAllocString(str);
 
    AutoWrap(DISPATCH_METHOD, &xlBook, xlBooks.pdispVal, L"Open", 1, vaPath);
 
    SysFreeString(vaPath.bstrVal);
	VariantClear(&vaPath);
 
	return true;
}
 
bool MyExcel::IsExcelRunning()
{
	if (xlApp.pdispVal == NULL) return false;
	if (!FindWindow(L"XLMAIN",NULL))return false;
	return true;
}
 
bool MyExcel::SetVisible(bool fVisible)
{
	VariantClear(&lgVariant);
	lgVariant.vt = VT_I4;
	lgVariant.lVal = fVisible;
	HRESULT hr = AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlApp.pdispVal, L"Visible", 1, lgVariant);
 
	return true;
}
 
bool MyExcel::ShowGrid(bool b)
{
	IDispatch *pXlWindows;
	IDispatch *pXlWindow;
 
	VariantInit(&strVariant);
	AutoWrap(DISPATCH_PROPERTYGET, &strVariant, xlApp.pdispVal, L"Windows", 0);
	pXlWindows = strVariant.pdispVal;
 
	VARIANT xwind;
	xwind.vt=VT_I4;
	xwind.lVal=1;
	VariantInit(&strVariant);
	AutoWrap(DISPATCH_PROPERTYGET, &strVariant, pXlWindows, L"Item", 1,xwind);
	pXlWindow = strVariant.pdispVal;
 
	VARIANT xprop;
	xprop.vt=VT_BOOL;
	xprop.boolVal=b;
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, pXlWindow, L"DisplayGridlines", 1,xprop);
 
	pXlWindows->Release();
	pXlWindow->Release();
 
	VariantClear(&xprop);
	VariantClear(&xwind);
 
	return true;
}
 
bool MyExcel::SetPic(char* file) 
{
	if (file == NULL) return false;
 
	WCHAR str[MAX_PATH];
	MultiByteToWideChar(CP_ACP, 0,file, -1, str, MAX_PATH);
 
	IDispatch *pXlShapes;
 
	VariantInit(&strVariant);
 
	AutoWrap(DISPATCH_PROPERTYGET, &strVariant, xlSheet.pdispVal, L"Shapes", 0);
	pXlShapes = strVariant.pdispVal;
 
	VARIANT fname;
	fname.vt = VT_BSTR;
	fname.bstrVal=SysAllocString(str);
	VARIANT xpropf;
	xpropf.vt=VT_BOOL;
	xpropf.boolVal=FALSE;
	VARIANT xpropt;
	xpropt.vt=VT_BOOL;
	xpropt.boolVal=TRUE;
 
	VARIANT xtop;
	xtop.vt=VT_R8;
	xtop.dblVal=10.0;
	VARIANT xleft;
	xleft.vt=VT_R8;
	xleft.dblVal=10.0;
	VARIANT xwidth;
	xwidth.vt=VT_R8;
	xwidth.dblVal=200.0;
	VARIANT xheight;
	xheight.vt=VT_R8;
	xheight.dblVal=200.0;
 
	//Les arguments doivent etre passé a l'envers
	AutoWrap(DISPATCH_METHOD, NULL, pXlShapes, L"AddPicture", 7,xheight,xwidth,xleft,xtop,xpropt,xpropf,fname);
 
	SysFreeString(fname.bstrVal);
 
	pXlShapes->Release();
 
	VariantClear(&xheight);
	VariantClear(&xwidth);
	VariantClear(&xleft);
	VariantClear(&xtop);
	VariantClear(&xpropt);
	VariantClear(&xpropf);
	VariantClear(&fname);
 
	return true;
}
 
bool MyExcel::GetWorkbook(int book) 
{
	VariantClear(&lgVariant);
	lgVariant.vt = VT_I4;
	lgVariant.lVal = book;
 
	//AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &xlBook, xlBooks.pdispVal, L"Workbooks", 1, lgVariant);
	//AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &xlBook, xlApp.pdispVal, L"Workbooks", 0);
	//AutoWrap(DISPATCH_PROPERTYGET, &xlBook, xlApp.pdispVal, L"Activebooks", 0);
 
	xlBook.pdispVal = xlApp.pdispVal;
 
	return true;
}
 
bool MyExcel::AddWorkbook(void) 
{
    AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &xlBook, xlBooks.pdispVal, L"Add", 0);
	return true;
}
 
bool MyExcel::SetWoksheetName(char *name) 
{
	WCHAR str[MAX_PATH];
	MultiByteToWideChar(CP_ACP, 0,name, -1, str, MAX_PATH);
 
	VARIANT parm;
	VariantClear(&parm);
	parm.vt = VT_BSTR;
	parm.bstrVal = SysAllocString(str);
 
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlSheet.pdispVal, L"Name", 1, parm);
 
	SysFreeString(parm.bstrVal);
	VariantClear(&parm);
 
	return true;
}
 
 
bool MyExcel::GetWorksheet(int sheet) 
{
	VariantClear(&lgVariant);
	lgVariant.vt = VT_I4;
	lgVariant.lVal = sheet;
 
	AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &xlSheet, xlBook.pdispVal, L"Worksheets", 1, lgVariant);
 
	return true;
}
 
bool MyExcel::AddWorksheet(void) 
{	
	VariantClear(&lgVariant);
	lgVariant.vt = VT_I4;
	lgVariant.lVal = 1;
 
	AutoWrap(DISPATCH_PROPERTYGET, &xlSheet, xlApp.pdispVal, L"Worksheets", 1, lgVariant);
 
    AutoWrap(DISPATCH_PROPERTYGET, &xlBook, xlSheet.pdispVal, L"Add", 0);
 
	return true;
}
 
bool MyExcel::SetSave(bool b) 
{
	// Set .Saved property of workbook to 'Saved'
	VariantClear(&lgVariant);
	lgVariant.vt = VT_I4;
	lgVariant.lVal = b;
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlBook.pdispVal, L"Saved", 1, lgVariant);	
 
	return true;
}
 
//*************************************************************************
 
bool MyExcel::Protect(char* pass) 
{
	WCHAR str[MAX_PATH];
	MultiByteToWideChar(CP_ACP, 0,pass, -1, str, MAX_PATH);
 
	VARIANT strVariant;
	VariantClear(&strVariant);
	strVariant.vt = VT_BSTR;
	strVariant.bstrVal = SysAllocString(str);
	AutoWrap(DISPATCH_METHOD, NULL, xlSheet.pdispVal, L"protect", 1, strVariant);
 
	SysFreeString(strVariant.bstrVal);
	VariantClear(&strVariant);
 
	return true;
}
 
bool MyExcel::UnProtect(char* pass) 
{
	WCHAR str[MAX_PATH];
	MultiByteToWideChar(CP_ACP, 0,pass, -1, str, MAX_PATH);
 
	VARIANT strVariant;
	VariantClear(&strVariant);
	strVariant.vt = VT_BSTR;
	strVariant.bstrVal = SysAllocString(str);
	AutoWrap(DISPATCH_METHOD, NULL, xlSheet.pdispVal, L"Unprotect", 1, strVariant);
 
	SysFreeString(strVariant.bstrVal);
	VariantClear(&strVariant);
 
	return true;
}
 
bool MyExcel::ResizeCell(char* pPos) 
{
	return false;
}
 
 
//************************************************************************
bool MyExcel::RunMacro(char* macro) 
{
	return false;
}
 
bool MyExcel::SelectRange(char* pPos) 
{
	if( pPos == NULL ) return false;
 
	WCHAR str[100];
	MultiByteToWideChar(CP_ACP, 0,pPos, -1, str, 100);
 
	//on selectionne
	VARIANT parm;
	parm.vt = VT_BSTR;
	parm.bstrVal = SysAllocString(str);
 
	VariantClear(&cellRange);
 
	AutoWrap(DISPATCH_PROPERTYGET, &cellRange, xlSheet.pdispVal, L"Range", 1, parm);
 
	SysFreeString(parm.bstrVal);
	VariantClear(&parm);
 
	return true;
}
 
bool MyExcel::SetColor(long c1,long c2) 
{
	IDispatch *pXlInside;
	//on selectionne l'interieur de la cellule
	VARIANT color;
 
	VariantInit(&strVariant);
	AutoWrap(DISPATCH_PROPERTYGET, &strVariant, cellRange.pdispVal, L"Interior", 0);
	pXlInside = strVariant.pdispVal;
	//on applique la couleur
	color.vt = VT_I4;
	color.lVal=c1;
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, pXlInside, L"Color",1,color);
 
	//on selectionne le texte
	AutoWrap(DISPATCH_PROPERTYGET, &xlFont, cellRange.pdispVal, L"Font", 0);
	//on chnage la couleur
	color.vt = VT_I4;
	color.lVal=c2;
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlFont.pdispVal, L"Color",1,color);
 
	VariantClear(&color);
	pXlInside->Release();
 
	return true;
}
 
bool MyExcel::SetFont(char *font,bool bold, bool under,int size) 
{
	if (&cellRange == NULL) return false;
 
	//convertion char to str
	WCHAR str[100];
	MultiByteToWideChar(CP_ACP, 0,font, -1, str, 100);
 
	//on selectionne le texte
	AutoWrap(DISPATCH_PROPERTYGET, &xlFont, cellRange.pdispVal, L"Font", 0);
 
	VARIANT xprop;
 
	//gras
	xprop.vt=VT_BOOL;
	xprop.boolVal=bold;
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlFont.pdispVal, L"Bold", 1,xprop);
 
	//italique
	xprop.vt=VT_I4;
	xprop.lVal=1;
	if (under) xprop.lVal=2;
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlFont.pdispVal, L"Underline", 1,xprop);
 
	//police
	if (font != NULL) 
	{
		VariantInit(&xprop);
		xprop.vt = VT_BSTR;
		xprop.bstrVal = SysAllocString(str);
		AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlFont.pdispVal, L"Name", 1,xprop);
		SysFreeString(xprop.bstrVal);
	}
 
	//taille
	if (size > 0 ) 
	{
		VariantInit(&xprop);
		xprop.vt = VT_I4;
		xprop.lVal=size;
		AutoWrap(DISPATCH_PROPERTYPUT, NULL, xlFont.pdispVal, L"Size",1,xprop);
	}
 
	VariantClear(&xprop);
 
	return true;
}
 
//*********************************************************************************************
 
bool MyExcel::GetData(char* pPos, char* pData)
{
	if (pData == NULL) return false;
 
	//on selectionne une zone ou cellule
	if (!SelectRange(pPos)) return false;
 
	//on lit la selection
	VariantClear(&cellValue);
	cellValue.vt=VT_BSTR;
	AutoWrap(DISPATCH_PROPERTYGET, &cellValue, cellRange.pdispVal, L"Value", 0, 0);
 
	if (cellValue.vt==VT_EMPTY)
	{
		pData[0]='\0';
	}
	else
	{
		VariantChangeType(&cellValue, &cellValue, VARIANT_NOUSEROVERRIDE, VT_BSTR);
 
		//int length = WideCharToMultiByte (CP_ACP,0, tmp.bstrVal,SysStringLen(tmp.bstrVal), pData, sizeof(pData)-1,NULL, NULL);
		//pData[length] = '\0';
		BSTRtoASC(cellValue.bstrVal,pData);
	}
	// Release references...
	VariantClear(&cellValue);
	VariantClear(&cellRange);
 
	return true;
}
 
bool MyExcel::SetData(char* pPos, char* pData)
{
	if(pData == NULL) return false;
 
	//on selctionne une zone ou cellule
	if (!SelectRange(pPos)) return false;
 
	// On ecrit nos valeurs dans la selection
	WCHAR str2[255];
	MultiByteToWideChar(CP_ACP, 0,pData, -1, str2 , 255);
 
	VariantClear(&cellValue);
	cellValue.vt=VT_BSTR;
	cellValue.bstrVal=SysAllocString(str2);
 
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, cellRange.pdispVal, L"Value", 1, cellValue);
 
	// Release references...
	VariantClear(&cellValue);
	//VariantClear(&cellRange);
 
	return true;
}
 
//******************************************************************************************
 
bool MyExcel::CopyDataRange(char* pPos1, char* pPos2)
{
	if ( pPos2 == NULL ) return false;
 
	//initialisation du tableau qui va receuillir les données
	VariantClear(&arr);
	arr.vt=VT_BSTR;
	//arr.vt = VT_ARRAY | VT_VARIANT;
 
	//on selectionne la zone ou on va copier
	if (!SelectRange(pPos1)) return false;
	//on copie
	AutoWrap(DISPATCH_PROPERTYGET, &arr, cellRange.pdispVal, L"Value", 0, 0);
 
	//on selectionne la zone ou on va coller
	if (!SelectRange(pPos2)) return false;
	//On colle
	AutoWrap(DISPATCH_PROPERTYPUT, NULL, cellRange.pdispVal, L"Value", 1, arr);
 
	// Release references...
	VariantClear(&cellRange);
 
	return true;
}
 
//***********************************************************************
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/06/2008, 23h57   #12
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
si je rajoute :

Code :
1
2
3
4
5
#define DEFINE_GUIDSTRUCT(g, n) struct __declspec(uuid(g)) n
#define DEFINE_GUIDNAMED(n) n
 
DEFINE_GUIDSTRUCT("00000000-0000-0000-0000-000000000000", GUID_NULL);
#define GUID_NULL DEFINE_GUIDNAMED(GUID_NULL)
j'ai deux erreurs :

Code :
1
2
3
4
1>.\libExcel\excel.cpp(73) : error C2275: 'GUID_NULL'*: utilisation non conforme de ce type comme expression
1>        .\libExcel\excel.cpp(25)*: voir la déclaration de 'GUID_NULL'
1>.\libExcel\excel.cpp(102) : error C2275: 'GUID_NULL'*: utilisation non conforme de ce type comme expression
1>        .\libExcel\excel.cpp(25)*: voir la déclaration de 'GUID_NULL'
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2008, 00h22   #13
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
le problème viens de excel.cpp a ce passage:

Code :
hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
et a celui la :

Code :
hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, NULL, NULL);
si je déclare

et que je remplace les deux IID_NULL par gag sa compile mais sa echoue lamentablement a l'execution ... faut peut être initialiser gag ou remplacer IID_NULL par autre chose.
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2008, 09h06   #14
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Homme
Développeur informatique
Inscription : septembre 2005
Messages : 21 338
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 28
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : septembre 2005
Messages : 21 338
Points : 28 440
Points : 28 440
Envoyer un message via MSN à Médinoc
Puisque tu es sous Visual, essaie de remplacer IID_NULL par __uuidof(0)
__________________
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone.
-- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Médinoc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2008, 10h51   #15
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
mue je sais plus trop ou j'en suis la ...
j'arrive plus à retrouver comment j'arrivais à compiler en remplaçant par un IID

La ça me met
Code :
1
2
1>excel.obj : error LNK2020: jeton non résolu (0A000014) IID_IDispatch
1>excel.obj : error LNK2001: symbole externe non résolu IID_IDispatch
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2008, 10h59   #16
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Homme
Développeur informatique
Inscription : septembre 2005
Messages : 21 338
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 28
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : septembre 2005
Messages : 21 338
Points : 28 440
Points : 28 440
Envoyer un message via MSN à Médinoc
Essaie __uuidof(IDispatch) à la place.
__________________
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone.
-- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Médinoc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2008, 13h09   #17
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
Code :
1
2
1>excel.obj : error LNK2020: jeton non résolu (0A00000F) IID_IDispatch
1>excel.obj : error LNK2001: symbole externe non résolu IID_IDispatch
sa doit venir de la :
Code :
  if (FAILED(CoCreateInstance(clsExcelApp, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&xlApp.pdispVal)))
et de la :
Code :
hr2=pUnk->QueryInterface(IID_IDispatch, (void **)&xlApp.pdispVal);
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/06/2008, 13h50   #18
Invité de passage
 
Étudiant
Inscription : juin 2008
Messages : 29
Détails du profil
Informations personnelles :
Âge : 25

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2008
Messages : 29
Points : 2
Points : 2
je crois que je vais changer de classe pour lire un fichier excel celle présenté sur developpez.com en c# ou il faut ajouter la librairie excel.
Le problème c'est que j'arrive pas a ajouter la librairie excel dans un projet c++
Sekhmett est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/04/2009, 10h36   #19
Invité de passage
 
Inscription : avril 2009
Messages : 4
Détails du profil
Informations forums :
Inscription : avril 2009
Messages : 4
Points : 4
Points : 4
Par défaut Exactement le même pb

Bonjour,

j'ai exactement le même problème. Cependant la solution donnée dans ce post ne fonctionne pas ou je l'applique mal ce qui est fort possible. Je me permet donc de déterrer la discussion.

J'ai en effet essayé d'ajouter :
Code :
1
2
3
4
5
 
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "oleaut32.lib")
#pragma comment(lib, "ole32.lib")
mais cela ne change rien. J'ai toujours les messages d'erreur :
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
 
1>------ Début de la génération*: Projet*: TestOracleAvecInterface, Configuration*: Debug Win32 ------
1>Édition des liens en cours...
1>testbase.obj : error LNK2028: jeton non résolu (0A00000A) "extern "C" short __stdcall SQLFreeEnv(void *)" (?SQLFreeEnv@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A00000B) "extern "C" short __stdcall SQLFreeConnect(void *)" (?SQLFreeConnect@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A00000C) "extern "C" short __stdcall SQLDisconnect(void *)" (?SQLDisconnect@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A00000E) "extern "C" short __stdcall SQLFetch(void *)" (?SQLFetch@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A00000F) "extern "C" short __stdcall SQLBindCol(void *,unsigned short,short,void *,long,long *)" (?SQLBindCol@@$$J224YGFPAXGF0JPAJ@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A000010) "extern "C" short __stdcall SQLExecDirectW(void *,wchar_t *,long)" (?SQLExecDirectW@@$$J212YGFPAXPA_WJ@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A000011) "extern "C" short __stdcall SQLAllocStmt(void *,void * *)" (?SQLAllocStmt@@$$J18YGFPAXPAPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A000012) "extern "C" short __stdcall SQLConnectW(void *,wchar_t *,short,wchar_t *,short,wchar_t *,short)" (?SQLConnectW@@$$J228YGFPAXPA_WF1F1F@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A000013) "extern "C" short __stdcall SQLAllocConnect(void *,void * *)" (?SQLAllocConnect@@$$J18YGFPAXPAPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A000015) "extern "C" short __stdcall SQLAllocEnv(void * *)" (?SQLAllocEnv@@$$J14YGFPAPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2028: jeton non résolu (0A000016) "extern "C" short __stdcall SQLGetDiagRecW(short,void *,short,wchar_t *,long *,wchar_t *,short,short *)" (?SQLGetDiagRecW@@$$J232YGFFPAXFPA_WPAJ1FPAF@Z) référencé dans la fonction "private: void __clrcall testbase::afficherErreurs(char *,short,short,void *)" (?afficherErreurs@testbase@@$$FA$AAMXPADFFPAX@Z)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLGetDiagRecW(short,void *,short,wchar_t *,long *,wchar_t *,short,short *)" (?SQLGetDiagRecW@@$$J232YGFFPAXFPA_WPAJ1FPAF@Z) référencé dans la fonction "private: void __clrcall testbase::afficherErreurs(char *,short,short,void *)" (?afficherErreurs@testbase@@$$FA$AAMXPADFFPAX@Z)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLFreeEnv(void *)" (?SQLFreeEnv@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLFreeConnect(void *)" (?SQLFreeConnect@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLDisconnect(void *)" (?SQLDisconnect@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLFetch(void *)" (?SQLFetch@@$$J14YGFPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLBindCol(void *,unsigned short,short,void *,long,long *)" (?SQLBindCol@@$$J224YGFPAXGF0JPAJ@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLExecDirectW(void *,wchar_t *,long)" (?SQLExecDirectW@@$$J212YGFPAXPA_WJ@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLAllocStmt(void *,void * *)" (?SQLAllocStmt@@$$J18YGFPAXPAPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLConnectW(void *,wchar_t *,short,wchar_t *,short,wchar_t *,short)" (?SQLConnectW@@$$J228YGFPAXPA_WF1F1F@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLAllocConnect(void *,void * *)" (?SQLAllocConnect@@$$J18YGFPAXPAPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>testbase.obj : error LNK2019: symbole externe non résolu "extern "C" short __stdcall SQLAllocEnv(void * *)" (?SQLAllocEnv@@$$J14YGFPAPAX@Z) référencé dans la fonction "public: void __clrcall testbase::remplirChaine(void)" (?remplirChaine@testbase@@$$FQ$AAMXXZ)
1>D:\Hugues\TestODBCAvecInterface\TestOracleAvecInterface\Debug\TestOracleAvecInterface.exe : fatal error LNK1120: 22 externes non résolus
1>Le journal de génération a été enregistré à l'emplacement "file://d:\Hugues\TestODBCAvecInterface\TestOracleAvecInterface\TestOracleAvecInterface\Debug\BuildLog.htm"
1>TestOracleAvecInterface - 23 erreur(s), 0 avertissement(s)
========== Génération*: 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========
J'ajoute que le code sur lequel l'édition des liens ne fonctionne pas ne pose pas de problème dans un projet sous visual en application console.

Je pense que le problème vient d'un problème d'inclusion des librairies ou bien d'un problème de code managé/non managé. Etant novice sous visual, quelqu'un peut-il m'aider?

Je n'ai pas mis le code pour ne pas alourdir le message mais peut le mettre si cela s'avère utile pour le diagnostic.

Merci.
hugum est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/04/2009, 11h26   #20
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Homme
Développeur informatique
Inscription : septembre 2005
Messages : 21 338
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 28
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : septembre 2005
Messages : 21 338
Points : 28 440
Points : 28 440
Envoyer un message via MSN à Médinoc
Essaie de lier à odbc32.lib
__________________
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone.
-- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Médinoc est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +1. Il est actuellement 05h58.


 
 
 
 
Partenaires

Hébergement Web