Potrebuju aby z ceckovyho programu sli pod Windows spoustet zaregistrovany soubory. Nasel jsem si, ze se musi pouzit API fce ShellExecute:
Mel bych nasledujici dotazy:Kód:#include <stdio.h> #include <shellapi.h> /*#define nazev "\\html\\index.html"*/ #define nazev "d:\\vyuka\\cecko\\spousteni\\html\\index.html" /* #define nazev "index.html" */ int main(void) { printf("%s", nazev); /* sprintf(command,"\"f:\\program files\\internet explorer\\iexplore\" %s", nazev); system(command); */ ShellExecute(NULL, "open", nazev, NULL, ".", SW_SHOWNORMAL); return (0); }
1) Ta fce ShellExecute ma vracet jestli to probehlo OK atd. Nevim ale, jak z ni dostat. Typ funkce ma byt HINSTANCE, coz netusim, co je (teda je to nejakej ukazatel, ci co?).
2) Dalsi problem je, ze to funguje jen s uplnou cestou a ne s relativni vzhledem k adresari, ze kteryho to poustim. Zrejme budu muset nejdriv zjistit cestu.
Kód:int main (int argc, char *argv[]) .... program_name = argv[0];
3) Co delat v pripade, ze argv[0] zklame? Ze muze je patrne z nasledujiciho:
Pouzivam LCC kompilator a argv[0] vyhodi jen nazev spousteneho souboruargv[0] may contain all or part of the pathname, or it may contain nothing. You may be able to duplicate the command language interpreter's search path logic to locate the executable if the name in argv[0] is present but incomplete. However, there is no guaranteed solution.
Budu vdecny za jakykoliv namet![]()