Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Save bug
#1
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.
#2
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".
#3
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.
#4
See also "possible reason 2" in my previous post.

To see the real path, run this code in QM and in .exe

Code:
Copy      Help
out _s.expandpath("$my qm$\test.rtf")

This is my test code, it runs without errors.
Macro Macro3236
Code:
Copy      Help
;/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
#5
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?
#6
str.setfile code is like this. Maybe helps to debug.

Macro Macro3246
Code:
Copy      Help
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"


Forum Jump:


Users browsing this thread: 1 Guest(s)