Posts: 24
Threads: 9
Joined: Feb 2014
I think I found a bug...
I'm opening a file with the following function:
function str'T
str File="$my qm$\test.rtf"
T.setfile(File -1 -1 1)
Here's where the bug comes in. If I compile my code into an EXE it throws an error:
Error (RT) in <open "CreatFile /47">CreateFile: cannot open or create file: Access is denied. (0x5). <help #IDP_ERR>?
Now... if I run that file manually in the QM interface, it has no problems whatsoever. Only happens when I attempt to run it after its compiled to an EXE.
Posts: 12,072
Threads: 140
Joined: Dec 2002
10-13-2022, 02:33 PM
(This post was last modified: 10-13-2022, 02:38 PM by Gintaras.)
Possible reason 1 - the file is in a folder where non-admin programs cannot write.
Let the exe program run as administrator.
Or move the file to a folder where non-admin programs can write.
Possible reason 2 - $my qm$ is a different folder in exe than in QM. Maybe even does not exist.
Don't use $my qm$ in exe. Maybe it's a wrong answer, I don't remember, probably it is documented in Help topic "Make exe".
Posts: 24
Threads: 9
Joined: Feb 2014
Tried that... same result. The EXE throws the same error everytime, whether I run as an Administrator or not. Try it yourself. You'll see.
Posts: 12,072
Threads: 140
Joined: Dec 2002
See also "possible reason 2" in my previous post.
To see the real path, run this code in QM and in .exe
out _s.expandpath("$my qm$\test.rtf")
This is my test code, it runs without errors.
Macro
Macro3236
;/exe
out _s.expandpath("$my qm$\test.rtf")
str T="test"
str File="$my qm$\test.rtf"
T.setfile(File -1 -1 1)
;BEGIN PROJECT
;main_function Macro3236
;exe_file $my qm$\Macro3236.exe
;icon <default>
;manifest $qm$\default.exe.manifest
;flags 6
;guid {3869B3AD-2349-49B1-B318-62BE747900DB}
;END PROJECT
Posts: 24
Threads: 9
Joined: Feb 2014
I tried it again multiple times... same problem. I used your code... get the same folder/directory in both the compiled and when run thru the user interface. It runs fine when run via the interface but continues to throw the error:
"Error (RT) in <open "CreateRTF /87">CreateRTF: cannot open or create file: Access is denied. (0x5). <help #IDP_ERR>?"
I've check the folder permissions and attempted running it in Admin mode... thought maybe the EXE permission settings might be causing it but nope. Getting the same error everytime no matter what I have tried. I'm going to try it on a different computer later tonight and see if there maybe a virus scanner or firewall that may be mistaking it for a virus and causing that error to come up. I'll have to check the permissions on the anti malware and it's possible it's causing the problem. But then why would it work in the actual user interface but not when it's compiled? Does that make any sense?
Posts: 12,072
Threads: 140
Joined: Dec 2002
str.setfile code is like this. Maybe helps to debug.
Macro
Macro3246
str path = "C:\Test\test.txt"
str data="test[]"
int append=1
__HFile f.Create(path iif(append OPEN_ALWAYS CREATE_ALWAYS) GENERIC_WRITE FILE_SHARE_READ)
if(append)
,LARGE_INTEGER li0; if(!SetFilePointerEx(f li0 0 FILE_END)) end "" 16 ;;move file pointer to the end
if(!WriteFile(f data data.len &_i 0)) end "" 16
f.Close
out "ok"