<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GetOpenFileName]]></title><description><![CDATA[<p>hallo leute,</p>
<p>warum macht der code hier nicht was er soll <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
<pre><code>.386
.model flat, stdcall
option casemap:none

include /masm32/include/windows.inc
include /masm32/include/comdlg32.inc
include /masm32/include/kernel32.inc
include /masm32/include/user32.inc

includelib /masm32/lib/comdlg32.lib
includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/user32.lib

m2m MACRO M1, M2
push M2
pop M1
ENDM

ZeroMem macro dest, len
mov ebx, dest
mov ecx, len
L1:
mov byte ptr [ebx+ecx], 0
loop L1
endm

.const
nMaxFile equ 260

.data
szFilter db &quot;Cursor (*.cur)&quot;,0,&quot;*.cur&quot;,0,0

.data?
szFile db nMaxFile dup(?)
ofn OPENFILENAME&lt;&gt;

.code

_start:

ZeroMem offset ofn, sizeof ofn

mov ofn.lStructSize, sizeof ofn
m2m ofn.lpstrFile, offset szFile
mov ofn.lpstrFile[0], 0
mov ofn.nMaxFile, nMaxFile
m2m ofn.lpstrFilter, offset szFilter
mov ofn.nFilterIndex, 1
mov ofn.Flags, OFN_PATHMUSTEXIST or OFN_FILEMUSTEXIST

invoke GetOpenFileName, addr ofn
.if eax!=0
invoke MessageBoxA, 0, addr ofn.lpstrFile, 0, 0
.endif
invoke ExitProcess,0

end _start
</code></pre>
<p>eigentlich sollte ein Datei-Öffnen-Dialog erscheinen (tut er auch), und der das Ergebnis/der Dateiname in einer MsgBox angezeigt werden. eax != 0 bedeutet, dass der aufruf erfolgreich war, jetzt sollte der dateiname in ofn.lpstrFile stehen, die msgbox zeigt aber immer einen leeren string an, woran liegts?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/233763/getopenfilename</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 20:45:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/233763.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Feb 2009 21:48:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetOpenFileName on Sun, 08 Feb 2009 21:48:43 GMT]]></title><description><![CDATA[<p>hallo leute,</p>
<p>warum macht der code hier nicht was er soll <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
<pre><code>.386
.model flat, stdcall
option casemap:none

include /masm32/include/windows.inc
include /masm32/include/comdlg32.inc
include /masm32/include/kernel32.inc
include /masm32/include/user32.inc

includelib /masm32/lib/comdlg32.lib
includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/user32.lib

m2m MACRO M1, M2
push M2
pop M1
ENDM

ZeroMem macro dest, len
mov ebx, dest
mov ecx, len
L1:
mov byte ptr [ebx+ecx], 0
loop L1
endm

.const
nMaxFile equ 260

.data
szFilter db &quot;Cursor (*.cur)&quot;,0,&quot;*.cur&quot;,0,0

.data?
szFile db nMaxFile dup(?)
ofn OPENFILENAME&lt;&gt;

.code

_start:

ZeroMem offset ofn, sizeof ofn

mov ofn.lStructSize, sizeof ofn
m2m ofn.lpstrFile, offset szFile
mov ofn.lpstrFile[0], 0
mov ofn.nMaxFile, nMaxFile
m2m ofn.lpstrFilter, offset szFilter
mov ofn.nFilterIndex, 1
mov ofn.Flags, OFN_PATHMUSTEXIST or OFN_FILEMUSTEXIST

invoke GetOpenFileName, addr ofn
.if eax!=0
invoke MessageBoxA, 0, addr ofn.lpstrFile, 0, 0
.endif
invoke ExitProcess,0

end _start
</code></pre>
<p>eigentlich sollte ein Datei-Öffnen-Dialog erscheinen (tut er auch), und der das Ergebnis/der Dateiname in einer MsgBox angezeigt werden. eax != 0 bedeutet, dass der aufruf erfolgreich war, jetzt sollte der dateiname in ofn.lpstrFile stehen, die msgbox zeigt aber immer einen leeren string an, woran liegts?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1660219</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1660219</guid><dc:creator><![CDATA[president evil]]></dc:creator><pubDate>Sun, 08 Feb 2009 21:48:43 GMT</pubDate></item><item><title><![CDATA[Reply to GetOpenFileName on Sun, 08 Feb 2009 22:24:00 GMT]]></title><description><![CDATA[<p>Die MessageBoxA braucht als zweiten Parameter nicht die Adresse von &quot;ofn.lpstrFile&quot;, sondern den &quot;Betrag&quot; von &quot;ofn.lpstrFile&quot;.<br />
&quot;ofn.lpstrFile&quot; enthält nach erfolgreichem Aufruf ein Zeiger zum Text. Probier mal so (falls das geht) :</p>
<pre><code class="language-asm">invoke MessageBoxA, 0, ofn.lpstrFile, 0, 0
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1660237</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1660237</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 08 Feb 2009 22:24:00 GMT</pubDate></item><item><title><![CDATA[Reply to GetOpenFileName on Mon, 09 Feb 2009 15:46:43 GMT]]></title><description><![CDATA[<p>+gjm+ schrieb:</p>
<blockquote>
<p>Die MessageBoxA braucht als zweiten Parameter nicht die Adresse von &quot;ofn.lpstrFile&quot;, sondern den &quot;Betrag&quot; von &quot;ofn.lpstrFile&quot;.<br />
&quot;ofn.lpstrFile&quot; enthält nach erfolgreichem Aufruf ein Zeiger zum Text. Probier mal so (falls das geht) :</p>
<pre><code class="language-asm">invoke MessageBoxA, 0, ofn.lpstrFile, 0, 0
</code></pre>
</blockquote>
<p>ne so funktionierts nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1660560</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1660560</guid><dc:creator><![CDATA[president evil]]></dc:creator><pubDate>Mon, 09 Feb 2009 15:46:43 GMT</pubDate></item><item><title><![CDATA[Reply to GetOpenFileName on Mon, 09 Feb 2009 16:05:07 GMT]]></title><description><![CDATA[<p>president evil schrieb:</p>
<blockquote>
<p>ne so funktionierts nicht.</p>
</blockquote>
<p>Das ist keine Fehlerbeschreibung...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1660567</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1660567</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Mon, 09 Feb 2009 16:05:07 GMT</pubDate></item><item><title><![CDATA[Reply to GetOpenFileName on Mon, 09 Feb 2009 17:42:02 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>president evil schrieb:</p>
<blockquote>
<p>ne so funktionierts nicht.</p>
</blockquote>
<p>Das ist keine Fehlerbeschreibung...</p>
</blockquote>
<p>es erscheint weiterhin ein leerer string in der messagebox.</p>
<p>wenn ich dasselbe programm in C schreibe, klappt alles. bin mir da auch mit dem zeromem macro nicht so ganz sicher. in C verwendet man ZeroMemory (ein macro für, ich glaube, memset). wie kann ich die funktion memset in asm aufrufen? wenn ich die msvcrt lib+inc einbinde kommt trotzdem der fehler &quot;unknown symbol: memset&quot; (oder so ähnlich).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1660643</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1660643</guid><dc:creator><![CDATA[president evil]]></dc:creator><pubDate>Mon, 09 Feb 2009 17:42:02 GMT</pubDate></item><item><title><![CDATA[Reply to GetOpenFileName on Mon, 09 Feb 2009 18:18:53 GMT]]></title><description><![CDATA[<p>Oh, sehe ich jetzt erst. Nimm mal folgende Zeile raus:</p>
<pre><code class="language-asm">(...)
mov ofn.lStructSize, sizeof ofn
m2m ofn.lpstrFile, offset szFile
; mov ofn.lpstrFile[0], 0                  ; &lt;- die hier
mov ofn.nMaxFile, nMaxFile
m2m ofn.lpstrFilter, offset szFilter
(...)
invoke MessageBoxA, 0, ofn.lpstrFile, 0, 0 ; &lt;- soll so bleiben
</code></pre>
<p>Ist irgendwie unlogisch, &quot;ofn.lpstrFile&quot; zu initialisieren und gleich danach wieder zu verändern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1660682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1660682</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 09 Feb 2009 18:18:53 GMT</pubDate></item><item><title><![CDATA[Reply to GetOpenFileName on Mon, 09 Feb 2009 18:48:21 GMT]]></title><description><![CDATA[<p>+gjm+ schrieb:</p>
<blockquote>
<p>Oh, sehe ich jetzt erst. Nimm mal folgende Zeile raus:</p>
<pre><code class="language-asm">(...)
mov ofn.lStructSize, sizeof ofn
m2m ofn.lpstrFile, offset szFile
; mov ofn.lpstrFile[0], 0                  ; &lt;- die hier
mov ofn.nMaxFile, nMaxFile
m2m ofn.lpstrFilter, offset szFilter
(...)
invoke MessageBoxA, 0, ofn.lpstrFile, 0, 0 ; &lt;- soll so bleiben
</code></pre>
<p>Ist irgendwie unlogisch, &quot;ofn.lpstrFile&quot; zu initialisieren und gleich danach wieder zu verändern.</p>
</blockquote>
<p>besten dank, so klappts! hatte das falsch aus dem C-code übertragen. dort muss man <code>ofn.lpstrFile[0] = '\0';</code> schreiben, da string sonst zur initialisierung verwendet wird.</p>
<p>msdn schrieb:</p>
<blockquote>
<p>// Set lpstrFile[0] to '\0' so that GetOpenFileName does not<br />
// use the contents of szFile to initialize itself.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1660723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1660723</guid><dc:creator><![CDATA[president evil]]></dc:creator><pubDate>Mon, 09 Feb 2009 18:48:21 GMT</pubDate></item></channel></rss>