Url en c

Fermé
seo610 Messages postés 596 Date d'inscription mardi 9 février 2010 Statut Membre Dernière intervention 30 juin 2015 - 25 mai 2010 à 02:42
SchSoftware Messages postés 46 Date d'inscription lundi 17 mai 2010 Statut Membre Dernière intervention 17 avril 2011 - 28 mai 2010 à 02:11
Bonjour,

comment faire un programme en c (en console) qui ouvre une url dans le navigateur web par défaut?
merci

4 réponses

SchSoftware Messages postés 46 Date d'inscription lundi 17 mai 2010 Statut Membre Dernière intervention 17 avril 2011 3
25 mai 2010 à 10:28
Bonjours

Quel OS?
Quel compilateur?

Bien à vous
0
seo610 Messages postés 596 Date d'inscription mardi 9 février 2010 Statut Membre Dernière intervention 30 juin 2015 102
26 mai 2010 à 00:14
Windows vista, dev c++
0
SchSoftware Messages postés 46 Date d'inscription lundi 17 mai 2010 Statut Membre Dernière intervention 17 avril 2011 3
27 mai 2010 à 02:05
Bonsoir

Je ne connais pas bien la procédure pour compiler sous Dev C++, donc, je peu juste vous fournir la fonction à utiliser (pas la procédure pour créer l'application console.)

// il y a peu être des includes à mettre ici... Mais les quelles?

int main(int argc, char* argv[])
{
ShellExecute(GetActiveWindow(), _T("open"), _T("https://www.google.com/?gws_rd=ssl"), NULL, NULL, SW_SHOW);
return 0;
}


Voila, j'espère avoir un peu aider...
Bien à vous
0
seo610 Messages postés 596 Date d'inscription mardi 9 février 2010 Statut Membre Dernière intervention 30 juin 2015 102
27 mai 2010 à 04:12
merci pour votre réponse, mais ça ne marche pas ce truc.
0
fiddy Messages postés 11069 Date d'inscription samedi 5 mai 2007 Statut Contributeur Dernière intervention 23 avril 2022 1 844
27 mai 2010 à 08:41
Essaie ;
ShellExecute(NULL,open","https://www.google.com/?gws_rd=ssl",NULL,NULL,SW_SHOW);

Et n'oublie pas d'inclure Shellapi.h. Et enfin, si c'est le cas, dis plutôt le message d'erreur obtenu par le compilateur plutôt que de dire "ça ne marche pas".
0
seo610 Messages postés 596 Date d'inscription mardi 9 février 2010 Statut Membre Dernière intervention 30 juin 2015 102
27 mai 2010 à 23:14
Compilateur: Default compiler
Building Makefile: "C:\truc\Makefile.win"
Ex?ution de make...
make.exe -f "C:\truc\Makefile.win" all
gcc.exe -c u.c -o u.o -I"C:/Dev-Cpp/include"

In file included from u.c:2:
C:/Dev-Cpp/include/Shellapi.h:127: error: syntax error before "FILEOP_FLAGS"
C:/Dev-Cpp/include/Shellapi.h:128: error: syntax error before "PRINTEROP_FLAGS"

In file included from u.c:2:
C:/Dev-Cpp/include/Shellapi.h:131: error: syntax error before "DWORD"
C:/Dev-Cpp/include/Shellapi.h:133: error: syntax error before "uCallbackMessage"
C:/Dev-Cpp/include/Shellapi.h:134: error: syntax error before "uEdge"
C:/Dev-Cpp/include/Shellapi.h:135: error: syntax error before "rc"
C:/Dev-Cpp/include/Shellapi.h:136: error: syntax error before "lParam"
C:/Dev-Cpp/include/Shellapi.h:141: error: syntax error before "DWORD"
C:/Dev-Cpp/include/Shellapi.h:143: error: syntax error before "uID"
C:/Dev-Cpp/include/Shellapi.h:144: error: syntax error before "uFlags"
C:/Dev-Cpp/include/Shellapi.h:145: error: syntax error before "uCallbackMessage"

C:/Dev-Cpp/include/Shellapi.h:146: error: syntax error before "hIcon"
C:/Dev-Cpp/include/Shellapi.h:159: error: syntax error before "szTip"
C:/Dev-Cpp/include/Shellapi.h:164: error: syntax error before '}' token
C:/Dev-Cpp/include/Shellapi.h:167: error: syntax error before "DWORD"
C:/Dev-Cpp/include/Shellapi.h:169: error: syntax error before "uID"
C:/Dev-Cpp/include/Shellapi.h:170: error: syntax error before "uFlags"
C:/Dev-Cpp/include/Shellapi.h:171: error: syntax error before "uCallbackMessage"
C:/Dev-Cpp/include/Shellapi.h:172: error: syntax error before "hIcon"
C:/Dev-Cpp/include/Shellapi.h:185: error: syntax error before "szTip"
C:/Dev-Cpp/include/Shellapi.h:190: error: syntax error before '}' token
C:/Dev-Cpp/include/Shellapi.h:193: error: syntax error before "DWORD"
C:/Dev-Cpp/include/Shellapi.h:195: error: syntax error before "hwnd"
C:/Dev-Cpp/include/Shellapi.h:196: error: syntax error before "lpVerb"
C:/Dev-Cpp/include/Shellapi.h:197: error: syntax error before "lpFile"
C:/Dev-Cpp/include/Shellapi.h:198: error: syntax error before "lpParameters"
C:/Dev-Cpp/include/Shellapi.h:199: error: syntax error before "lpDirectory"
C:/Dev-Cpp/include/Shellapi.h:201: error: syntax error before "hInstApp"
C:/Dev-Cpp/include/Shellapi.h:202: error: syntax error before "lpIDList"

C:/Dev-Cpp/include/Shellapi.h:203: error: syntax error before "lpClass"
C:/Dev-Cpp/include/Shellapi.h:204: error: syntax error before "hkeyClass"
C:/Dev-Cpp/include/Shellapi.h:205: error: syntax error before "dwHotKey"
C:/Dev-Cpp/include/Shellapi.h:206: error: syntax error before "hIcon"
C:/Dev-Cpp/include/Shellapi.h:207: error: syntax error before "hProcess"
C:/Dev-Cpp/include/Shellapi.h:210: error: syntax error before "DWORD"
C:/Dev-Cpp/include/Shellapi.h:212: error: syntax error before "hwnd"
C:/Dev-Cpp/include/Shellapi.h:213: error: syntax error before "lpVerb"
C:/Dev-Cpp/include/Shellapi.h:214: error: syntax error before "lpFile"
C:/Dev-Cpp/include/Shellapi.h:215: error: syntax error before "lpParameters"
C:/Dev-Cpp/include/Shellapi.h:216: error: syntax error before "lpDirectory"
C:/Dev-Cpp/include/Shellapi.h:218: error: syntax error before "hInstApp"
C:/Dev-Cpp/include/Shellapi.h:219: error: syntax error before "lpIDList"
C:/Dev-Cpp/include/Shellapi.h:220: error: syntax error before "lpClass"
C:/Dev-Cpp/include/Shellapi.h:221: error: syntax error before "hkeyClass"
C:/Dev-Cpp/include/Shellapi.h:222: error: syntax error before "dwHotKey"
C:/Dev-Cpp/include/Shellapi.h:223: error: syntax error before "hIcon"

C:/Dev-Cpp/include/Shellapi.h:224: error: syntax error before "hProcess"
C:/Dev-Cpp/include/Shellapi.h:227: error: syntax error before "HWND"

C:/Dev-Cpp/include/Shellapi.h:229: error: syntax error before "pFrom"
C:/Dev-Cpp/include/Shellapi.h:230: error: syntax error before "pTo"
C:/Dev-Cpp/include/Shellapi.h:231: error: syntax error before "fFlags"
C:/Dev-Cpp/include/Shellapi.h:232: error: syntax error before "fAnyOperationsAborted"
C:/Dev-Cpp/include/Shellapi.h:233: error: syntax error before "hNameMappings"
C:/Dev-Cpp/include/Shellapi.h:234: error: syntax error before "lpszProgressTitle"
C:/Dev-Cpp/include/Shellapi.h:237: error: syntax error before "HWND"
C:/Dev-Cpp/include/Shellapi.h:239: error: syntax error before "pFrom"
C:/Dev-Cpp/include/Shellapi.h:240: error: syntax error before "pTo"
C:/Dev-Cpp/include/Shellapi.h:241: error: syntax error before "fFlags"
C:/Dev-Cpp/include/Shellapi.h:242: error: syntax error before "fAnyOperationsAborted"
C:/Dev-Cpp/include/Shellapi.h:243: error: syntax error before "hNameMappings"
C:/Dev-Cpp/include/Shellapi.h:244: error: syntax error before "lpszProgressTitle"

C:/Dev-Cpp/include/Shellapi.h:247: error: syntax error before "HICON"
C:/Dev-Cpp/include/Shellapi.h:249: error: syntax error before "dwAttributes"
C:/Dev-Cpp/include/Shellapi.h:250: error: syntax error before "szDisplayName"
C:/Dev-Cpp/include/Shellapi.h:250: error: 'MAX_PATH' undeclared here (not in a function)
C:/Dev-Cpp/include/Shellapi.h:251: error: syntax error before "szTypeName"
C:/Dev-Cpp/include/Shellapi.h:252: error: syntax error before '}' token
C:/Dev-Cpp/include/Shellapi.h:254: error: syntax error before "HICON"
C:/Dev-Cpp/include/Shellapi.h:256: error: syntax error before "dwAttributes"
C:/Dev-Cpp/include/Shellapi.h:257: error: syntax error before "szDisplayName"
C:/Dev-Cpp/include/Shellapi.h:258: error: syntax error before "szTypeName"
C:/Dev-Cpp/include/Shellapi.h:259: error: syntax error before '}' token
C:/Dev-Cpp/include/Shellapi.h:261: error: syntax error before "DWORD"
C:/Dev-Cpp/include/Shellapi.h:263: error: syntax error before "i64NumItems"

In file included from u.c:2:
C:/Dev-Cpp/include/Shellapi.h:267: error: syntax error before '*' token
C:/Dev-Cpp/include/Shellapi.h:267: error: syntax error before "int"
C:/Dev-Cpp/include/Shellapi.h:268: error: syntax error before "DragAcceptFiles"
C:/Dev-Cpp/include/Shellapi.h:269: error: syntax error before "DragFinish"
C:/Dev-Cpp/include/Shellapi.h:270: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:271: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:272: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:273: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:274: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:275: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:276: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:277: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:278: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:278: error: syntax error before "int"
C:/Dev-Cpp/include/Shellapi.h:279: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:279: error: syntax error before "int"
C:/Dev-Cpp/include/Shellapi.h:280: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:281: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:282: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:283: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:284: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:285: error: syntax error before "ShellAboutA"
C:/Dev-Cpp/include/Shellapi.h:286: error: syntax error before "ShellAboutW"
C:/Dev-Cpp/include/Shellapi.h:287: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:288: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:289: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:290: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:291: error: syntax error before "SHFileOperationA"
C:/Dev-Cpp/include/Shellapi.h:292: error: syntax error before "SHFileOperationW"
C:/Dev-Cpp/include/Shellapi.h:293: error: syntax error before "SHFreeNameMappings"
C:/Dev-Cpp/include/Shellapi.h:294: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:294: error: syntax error before '*' token
C:/Dev-Cpp/include/Shellapi.h:295: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:295: error: syntax error before '*' token
C:/Dev-Cpp/include/Shellapi.h:296: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:297: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:298: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:299: error: syntax error before "WINAPI"
C:/Dev-Cpp/include/Shellapi.h:321: error: syntax error before "NOTIFYICONDATA"
C:/Dev-Cpp/include/Shellapi.h:322: error: syntax error before "SHELLEXECUTEINFO"
C:/Dev-Cpp/include/Shellapi.h:323: error: syntax error before "SHFILEOPSTRUCT"
C:/Dev-Cpp/include/Shellapi.h:324: error: syntax error before "SHFILEINFO"
u.c: In function 'main':
u.c:5: error: 'NULL' undeclared (first use in this function)
u.c:5: error: (Each undeclared identifier is reported only once
u.c:5: error: for each function it appears in.)
u.c:5: error: 'open' undeclared (first use in this function)
u.c:5: error: syntax error before string constant
u.c:5: error: missing terminating " character
u.c: At top level:
C:/Dev-Cpp/include/Shellapi.h:250: error: storage size of 'szDisplayName' isn't known
C:/Dev-Cpp/include/Shellapi.h:257: error: storage size of 'szDisplayName' isn't known

make.exe: *** [u.o] Error 1

Ex?ution termin?


voila la liste d'erreur quand je compile ça :
#include <stdio.h>
#include <stdlib.h>
#include <Shellapi.h>
int main(int argc, char *argv[])
{
ShellExecute(NULL,open","www.google.com",NULL,NULL,SW_SHOW);
system("PAUSE");
return 0;
}
0
SchSoftware Messages postés 46 Date d'inscription lundi 17 mai 2010 Statut Membre Dernière intervention 17 avril 2011 3
28 mai 2010 à 02:11
Bonsoir

J'ai un doute (il est tard) (et j'ai pas ce compilateur pour tester)
Essayez d'inclure "Windows.h" avant "Shellapi.h"
#include <Windows.h>
#include <Shellapi.h>


Bien à vous

0