I have this code:
.elseif ax==IDM_SAVE
push hInstance
pop gofn.hInstance
push hMainWindow
pop gofn.hWndOwner
mov gofn.lpstrFilter,offset ProjectFilter
mov gofn.lpstrTitle,offset szSaveProject
invoke GetSaveFileName,addr gofn
or eax,eax
jz end_save
invoke SetWindowText,hWnd,gofn.lpstrFileTitle
invoke CreateFile,gofn.lpstrFile,GENERIC_READ+GENERIC_WRITE,\
FILE_SHARE_READ+FILE_SHARE_WRITE,0,CREATE_NEW+\
OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE+FILE_ATTRIBUTE_NORMAL,\
0
mov hProject,eax
invoke BuildProjectFile,hWnd
invoke CountBytes,addr ProjectFileBuffer
invoke WriteFile,hProject,addr ProjectFileBuffer,ecx,\
addr noBytesWritten,0
invoke CloseHandle,hProject
When i go back to load the file it isnt there... what is it? any ideas. Thanks in advance
Hello,
Try to simplify your CreateFile parameters. Here is how I use it :
xor ebx,ebx
invoke CreateFile,pFileName,GENERIC_WRITE,\
ebx,ebx,CREATE_ALWAYS,ebx,ebx
deleted
ok....it's not a binary value and cant be combinated. thanks
Thanks Vortex but it didn'r work. File disappears after the app is closed. thanks anyway
Hi xandaz,
invoke WriteFile,hProject,addr ProjectFileBuffer,ecx,\
addr noBytesWritten,0
BOOL WriteFile(
HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped
);
nNumberOfBytesToWrite is ecx in your case but what happened to this register?
Windows has a wonderful function called GetLastError. Strongly recommended!
Vortex. the bytes have been counted by a procedure and result is in ecx. It works. I open the file and there's the data just the way it should be. It's when i close the app that file disappears. Thanks a lot.
Hi xandaz!
Here application crash when closing, the file remain perfectly.
.if uMsg==WM_DESTROY
quit:
invoke CloseHandle,hProject
In theory this hProject is alredy closed ¿?
it keeps on. when i close the app the created files disappear. i need some help pls. thanks in advance
try not using the FILE_ATTRIBUTE_ARCHIVE flag :icon_idea:
i tried that. doesn't work either. all files created during the app run time disappear when app closes. thanks anyway
no HSE.... the hProject handle gets freed at WM_DESTROY.
This can go on for weeks... unless you post complete code, of course.
you said it yourself.... i need a new approach to coding JJ. I have here a mix of Unicode and ANSI proceedings that are killing me.
Good news. It wasn't a coding error. it was running under Avast Sandbox. That's why the files disappeared. ohhh....sorry for troubling you guys. You deserve better. sorry for inconviniance. Thanks posse :thumbsup:
SandBox... :hmmm:
You don't have so much faith in your programming skills :biggrin:
Glad you solved it :thumbsup:
Thanks JJ. What do you mean exactely HSE. I put it there so the AV woudlnt nag me everytime i made a new build.
Quote from: xandaz on November 20, 2020, 08:44:06 PMI put it there so the AV woudlnt nag me everytime i made a new build.
Most if not all AV allow to exclude your \Masm32 folder (and all its subfolders) - a much better solution.
I would look for a better AV scanner, I personally use Kaspersky's KVRT.EXE which I download when I need it, run it then delete it. I absolutely don't want an AV scanner running all the time, if you have reasons to secure your computer for other people to use, set yourself up a separate profile that does not run the AV scanner all the time. On all of my boxes I have the default Microsoft AV running and it never caused me a problem.
While I was configuring one of the machines recently my catch it all "StartupMonitor" blocked something that was trying to install at startup so I used KVRT to fully remove it and it worked really well.
Yes. Thanks Hutch. Indeed Avast has an option to exclude a folder. Done that. Doing great. :thumbsup: