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 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
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>------ 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>------ 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
Vieux 24/06/2008, 12h54   #2 (permalink)
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Date d'inscription: septembre 2005
Localisation: Île-de-France
Âge: 26
Messages: 20 005
Envoyer un message via MSN à Médinoc
Par défaut

ole32.lib et oleaut32.lib
__________________
"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.

LA LOI HADOPI 1 A ÉTÉ REJETÉE, MAIS ON S'EST PRIS HADOPI 2 SUR LA FIGURE. NE LAISSONS PAS LOPPSI 2 PASSER!
Médinoc est actuellement connecté   Envoyer un message privé Réponse avec citation
Vieux 24/06/2008, 13h42   #3 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

merci medinoc mais il quand même 9 erreurs de lien
Une idée ?


Code :
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
Vieux 24/06/2008, 13h55   #4 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

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 :
#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
Vieux 24/06/2008, 15h17   #5 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

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>É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
Vieux 24/06/2008, 15h54   #6 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

Bon je trouve rien à ajouter dans le code le problème vien de la :

Code :
  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
Vieux 24/06/2008, 16h36   #7 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

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
Vieux 24/06/2008, 18h37   #8 (permalink)
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Date d'inscription: septembre 2005
Localisation: Île-de-France
Âge: 26
Messages: 20 005
Envoyer un message via MSN à Médinoc
Par défaut

Rajoute un #include <initguid.h> AVANT les autres includes dans L'UN de tes fichiers sources.
__________________
"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.

LA LOI HADOPI 1 A ÉTÉ REJETÉE, MAIS ON S'EST PRIS HADOPI 2 SUR LA FIGURE. NE LAISSONS PAS LOPPSI 2 PASSER!
Médinoc est actuellement connecté   Envoyer un message privé Réponse avec citation
Vieux 24/06/2008, 22h10   #9 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

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
Vieux 24/06/2008, 23h10   #10 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

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
Vieux 24/06/2008, 23h44   #11 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

si tu veux essayer chez toi

excel.h :
Code :
#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 :
//*************************************************************************************************************************************************************
//									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
Vieux 24/06/2008, 23h57   #12 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

si je rajoute :

Code :
#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>.\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
Vieux 25/06/2008, 00h22   #13 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

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

Code :
IID gag;
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
Vieux 25/06/2008, 09h06   #14 (permalink)
Expert Confirmé Sénior
 
Avatar de Médinoc
 
Date d'inscription: septembre 2005
Localisation: Île-de-France
Âge: 26
Messages: 20 005
Envoyer un message via MSN à Médinoc
Par défaut

Puisque tu es sous Visual, essaie de remplacer IID_NULL par __uuidof(0)
__________________
"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.

LA LOI HADOPI 1 A ÉTÉ REJETÉE, MAIS ON S'EST PRIS HADOPI 2 SUR LA FIGURE. NE LAISSONS PAS LOPPSI 2 PASSER!
Médinoc est actuellement connecté   Envoyer un message privé Réponse avec citation
Vieux 25/06/2008, 10h51   #15 (permalink)
Candidat au titre de Membre du Club
 
Date d'inscription: juin 2008
Localisation: Gers
Âge: 23
Messages: 26
Par défaut

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>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
NEWS C++FAQs C++Tutoriels C++Livres C++Outils & compilateurs C++Bibliothèques C++Sources C++Blog C++Qt

Réponse Proposer ce sujet en actualité

Précédent   Forum des professionnels en informatique > C et C++ > Outils pour C & C++ > Visual C++ > VC++ .NET



Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are non
Pingbacks are non
Refbacks are non



Fuseau horaire GMT +1. Il est actuellement 10h32.


Vos questions techniques : forum d'entraide C++ - Publiez vos articles, tutoriels et cours
et rejoignez-nous dans l'équipe de rédaction du club d'entraide des développeurs francophones
Nous contacter - Hébergement - Participez - Copyright © 2000-2010 www.developpez.com - Legal informations.