# HG changeset patch # User Matti Hamalainen # Date 1289980652 -7200 # Node ID e0ec2280a778a83914a2bb689784fee4311e46fc # Parent edd5ce3e5399d14e848d9a1913514ea91bd79ba1 Implement browser launching on Windows via ShellExecute(). diff -r edd5ce3e5399 -r e0ec2280a778 Makefile.w32 --- a/Makefile.w32 Wed Nov 17 05:13:12 2010 +0200 +++ b/Makefile.w32 Wed Nov 17 09:57:32 2010 +0200 @@ -11,7 +11,7 @@ CFLAGS=-DHAVE_STRING_H -Ipdcurses # Library path must be defined correctly here -LDFLAGS=-L/usr/local/i386-mingw32/lib/ -lmingw32 -liberty -lws2_32 -s +LDFLAGS=-L/usr/local/i386-mingw32/lib/ -liberty -lws2_32 -lole32 -s # Link PDCurses static library here .. you will want to change this ifeq ($(SDL),y) diff -r edd5ce3e5399 -r e0ec2280a778 nnchat.c --- a/nnchat.c Wed Nov 17 05:13:12 2010 +0200 +++ b/nnchat.c Wed Nov 17 09:57:32 2010 +0200 @@ -666,15 +666,22 @@ printMsg("Opening profile for: '%s'\n", name); tmpStr = nn_encode_str1(name); - snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr); +#ifdef __WIN32 + { + int status; + snprintf(tmpBuf, sizeof(tmpBuf), "http://www.newbienudes.com/profile/%s/", tmpStr); th_free(tmpStr); - -#ifdef __WIN32 - + status = ShellExecute(NULL, "open", tmpBuf, NULL, NULL, SW_SHOWNA); + if (status <= 32) + printMsg("Could not launch default web browser: %d\n", status); + } #else { int status; pid_t pid; + snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr); + th_free(tmpStr); + if ((pid = fork()) < 0) { printMsg("Could not create sub-process!\n"); } else if (pid == 0) { @@ -876,7 +883,7 @@ fputs(info, stdout); fgets(tmpBuf, sizeof(tmpBuf), stdin); - + for (bufLen = strlen(tmpBuf) - 1; bufLen > 0 && (tmpBuf[bufLen] == '\n' || tmpBuf[bufLen] == '\r' || th_isspace(tmpBuf[bufLen])); bufLen--) tmpBuf[bufLen] = 0; @@ -941,6 +948,8 @@ char tmpPath[MAX_PATH]; if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK) homeDir = th_strdup(tmpPath); + + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); } #else homeDir = th_strdup(getenv("HOME"));