Hello.
I am using the fallow code:
It works very well. Save files in D root folder for exemple.
But the file is locked for editing. I can't read this file with other applicative. Only open in read mode in Excel for exemple if this file is a .csv.
But the result in result=_lclose (handle); is >0, so, the result is correct.
Any Idea?
Thanks so Much
Hi bisewski,
1. Use SRC code to post your code, it will makes us easier to read your codes,
2. Actually those are obsolete WinAPI function, though it still works. Read this article carefully, File Operation via WinAPI , which you probably use it from there in your code.
3. Basically you have to change file security attribute. Open file property and check it's security attributes and use share access OF_SHARE_COMPAT, read description in the article. You may have to experiment yourself with this attribute, coz there's not enough example.
:D
#define OF_READ 0 #define OF_WRITE 1 #define OF_READWRITE 2 #define OF_SHARE_COMPAT 3 #define OF_SHARE_DENY_NONE 4 #define OF_SHARE_DENY_READ 5 #define OF_SHARE_DENY_WRITE 6 #define OF_SHARE_EXCLUSIVE 7 #import "kernel32.dll" int _lopen (string path, int of); int _lcreat (string path, int attrib); int _llseek (int handle, int offset, int origin); int _lread (int handle, string buffer, int bytes); int _lwrite (int handle, string buffer, int bytes); int _lclose (int handle); #import void WriteFile (string path, string buffer) { int count=StringLen (buffer); int result; int handle=_lopen (path,OF_WRITE); if(handle<0) { handle=_lcreat (path,0); if(handle<0) { return; } result=_lclose (handle); } handle=_lopen (path,OF_WRITE); if(handle<0) { return; } result=_llseek (handle,0,0); if(result<0) { return; } result=_lwrite (handle,buffer,count); if(result<0) result=_lclose (handle); if(result<0) { } }
Test...
Oh...cool...
Thanks for your help. I look for this...
Test...
Oh...cool...
Thanks for your help. I look for this...
I try to use handle=_lopen (path, OF_WRITE|OF_SHARE_DENY_NONE); write but the file continue inacessible...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello.
I am using the fallow code:
#define OF_READ 0
#define OF_WRITE 1
#define OF_READWRITE 2
#define OF_SHARE_COMPAT 3
#define OF_SHARE_DENY_NONE 4
#define OF_SHARE_DENY_READ 5
#define OF_SHARE_DENY_WRITE 6
#define OF_SHARE_EXCLUSIVE 7
#import "kernel32.dll"
int _lopen (string path, int of);
int _lcreat (string path, int attrib);
int _llseek (int handle, int offset, int origin);
int _lread (int handle, string buffer, int bytes);
int _lwrite (int handle, string buffer, int bytes);
int _lclose (int handle);
#import
void WriteFile (string path, string buffer)
{
int count=StringLen (buffer);
int result;
int handle=_lopen (path,OF_WRITE);
if(handle<0)
{
handle=_lcreat (path,0);
if(handle<0)
{
return;
}
result=_lclose (handle);
}
handle=_lopen (path,OF_WRITE);
if(handle<0)
{
return;
}
result=_llseek (handle,0,0);
if(result<0)
{
return;
}
result=_lwrite (handle,buffer,count);
if(result<0)
result=_lclose (handle);
if(result<0)
{
}
}
It works very well. Save files in D root folder for exemple.
But the file is locked for editing. I can't read this file with other applicative. Only open in read mode in Excel for exemple if this file is a .csv.
But the result in result=_lclose (handle); is >0, so, the result is correct.
Any Idea?
Thanks so Much