Posts: 795
Threads: 136
Joined: Feb 2009
Hi Gintaras, hi all
after reading QM reference, i'm not sure if i can attach an exe file to a macro, to preserve a certain version of this exe, and preventing
code failure when software is uptaded; it's a portable exe btw
It's the opposite of binding file resource to an QM exe...
I read about icons and image files, but nothing about exe file.
If yes, is it availbale as image resource, via resource:xxx syntax?
ty
Posts: 12,086
Threads: 142
Joined: Dec 2002
In Resources dialog:
Click the Add link and import the exe file.
Click the imported exe link and select menu item Insert name in code -> String or comments.
It inserts code like this:
;"resource:<Macro274>csc.exe"
You can remove the <Macro274> part if the resource belongs to the same macro.
Many QM file functions support such strings. For example, use str.getfile to get file data:
str s
;get exe file data from macro resources
s.getfile("resource:csc.exe")
;save as file
s.setfile("$temp$\csc.exe")
Posts: 795
Threads: 136
Joined: Feb 2009
Posts: 795
Threads: 136
Joined: Feb 2009
hmmm
function $files
"resource:<MKV>mkvmerge.exe"
str s
get exe file data from macro resources
s.getfile("resource:<MKV>mkvmerge.exe")
out s
MZЍ
MZЍ
MZЍ
something's wrong...
Posts: 12,086
Threads: 142
Joined: Dec 2002
This is what you should see when using out with binary data.
Function outb displays bytes in hex, optionally with text.
Posts: 795
Threads: 136
Joined: Feb 2009
i fully understand that, but s is supposed to be the exe name, so passed to function, no?
<so, there, it sys as expected that exe is missing or not found....
Posts: 12,086
Threads: 142
Joined: Dec 2002
Macro
Macro274
str s
;get exe file data from macro resources
s.getfile("resource:csc.exe")
;what is exe size?
out s.len
;save as file
s.setfile("$temp$\csc.exe")
;file exists?
out FileExists("$temp$\csc.exe") ;;says 1
Posts: 795
Threads: 136
Joined: Feb 2009
ok, seems i misunderstood the way you tell me to use it.
In fact, you show how to store it in macro, Qm can't use it as stored resource in the macro directly, must save it to disk, use the extracted exe, and then i
must delete it at the end of use of it.
Sorry, my bad, did not understand properly the proper way to do....i wanted the resource exe to be usable directly from the macro it's binded to...
Posts: 12,086
Threads: 142
Joined: Dec 2002
OS does not allow to execute exe and dll files directly from memory. Need a temporary file.
Posts: 795
Threads: 136
Joined: Feb 2009
Acknowledged, thread closed
Posts: 35
Threads: 16
Joined: Apr 2018
How can I get the full path from $temp$\csc.exe?
Posts: 35
Threads: 16
Joined: Apr 2018
Found it:
str v1
v1 = "$temp$\banorte_logo_slim.jpg"
out v1.expandpath