aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp?rev=1.2&content-type=text
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp?rev=1.2&content-type=text
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp?rev=1.2&content-type=text')
-rw-r--r--cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html98
1 files changed, 98 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html b/cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html
new file mode 100644
index 00000000..ae82c684
--- /dev/null
+++ b/cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp?rev=1.2&content-type=text/x-cvsweb-markup/index.html
@@ -0,0 +1,98 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
+<HEAD><style> A { color:black }</style>
+<!-- hennerik CVSweb $Revision: 1.93 $ -->
+<TITLE>code/tool/open_file/open_file.cpp - view - 1.2</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="open_file.cpp"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="open_file.cpp">open_file.cpp</A>
+ CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/tool/">tool</a> / <a href="/cvs/cvsweb.cgi/code/tool/open_file/">open_file</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/tool/">tool</a> / <a href="/cvs/cvsweb.cgi/code/tool/open_file/">open_file</a> / <a href="/cvs/cvsweb.cgi/code/tool/open_file/open_file.cpp">open_file.cpp</a>&nbsp;(<A HREF="/cvs/cvsweb.cgi/~checkout~/code/tool/open_file/open_file.cpp?rev=1.2" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/tool/open_file/open_file.cpp?rev=1.2','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
+Revision <B>1.2</B>, <i>Fri Dec 8 10:21:10 2000 UTC</i> (18 months, 3 weeks ago) by <i>corvazier</i>
+<BR>Branch: <b>MAIN</b>
+<BR>CVS Tags: <b>HEAD</b><BR>Changes since <b>1.1: +10 -3
+ lines</b><PRE>
+no message
+</PRE>
+</td></tr></table><HR noshade><PRE>// openhtml.cpp : Defines the entry point for the application.
+//
+
+#include &lt;windows.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;stdio.h&gt;
+
+LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata)
+{
+ &nbsp; &nbsp;HKEY hkey;
+ &nbsp; &nbsp;LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &amp;hkey);
+
+ &nbsp; &nbsp;if (retval == ERROR_SUCCESS)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp;long datasize = MAX_PATH;
+ &nbsp; &nbsp; &nbsp; &nbsp;TCHAR data[MAX_PATH];
+ &nbsp; &nbsp; &nbsp; &nbsp;RegQueryValue(hkey, NULL, data, &amp;datasize);
+ &nbsp; &nbsp; &nbsp; &nbsp;lstrcpy(retdata,data);
+ &nbsp; &nbsp; &nbsp; &nbsp;RegCloseKey(hkey);
+ &nbsp; &nbsp;}
+
+ &nbsp; &nbsp;return retval;
+}
+
+bool OpenFile (LPCTSTR filename, LPCTSTR ext, int showcmd)
+{
+ &nbsp; &nbsp;TCHAR key[MAX_PATH + MAX_PATH];
+
+ &nbsp; &nbsp;// First try ShellExecute()
+ &nbsp; &nbsp;HINSTANCE result = ShellExecute(NULL, &quot;open&quot;, filename, NULL,NULL, showcmd);
+
+ &nbsp; &nbsp;// If it failed, get the .htm regkey and lookup the program
+ &nbsp; &nbsp;if ((UINT)result &lt;= HINSTANCE_ERROR)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp;if (GetRegKey(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lstrcat(key, &quot;\\shell\\open\\command&quot;);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TCHAR *pos;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pos = strstr(key, &quot;\&quot;%1\&quot;&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (pos == NULL) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // No quotes found
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pos = strstr(key, &quot;%1&quot;); &nbsp; &nbsp; &nbsp; // Check for %1, without quotes
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (pos == NULL) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // No parameter at all...
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pos = key+lstrlen(key)-1;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*pos = '\0'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Remove the parameter
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*pos = '\0'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Remove the parameter
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lstrcat(pos, &quot; &quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lstrcat(pos, filename);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int res = WinExec(key,showcmd);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return (res&gt;31);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return true;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;return false;
+}
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HINSTANCE hPrevInstance,
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LPSTR &nbsp; &nbsp; lpCmdLine,
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int &nbsp; &nbsp; &nbsp; nCmdShow)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// TODO: Place code here.
+ &nbsp; &nbsp; &nbsp; &nbsp;if (strcmp (lpCmdLine, &quot;&quot;)==0)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox (NULL, &quot;Open a file with the default application.\nUsage: open_file [filepath]&quot;, &quot;Open file&quot;, MB_OK|MB_ICONINFORMATION);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char ext[512];
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_splitpath (lpCmdLine, NULL, NULL, NULL, ext);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OpenFile(lpCmdLine, ext, SW_SHOW);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;return 0;
+}
+</PRE> \ No newline at end of file