|
Well, the first thing is easy. Just try to open the file with write access and if it fails, try open it again using only the read parameter (Use CFile::Open, not the constructor). The second thing with the network ID is a bit harder and depends on your file server.
Isn't it CVS what you want?
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Hi,
Thank you for the reply.But how would I get the network ID..Could you please tell some steps to achieve this.
How will get a valid handle of the open file..how will I get the SECURITY_DESCRIPTOR pointer and computer name..or Is there some other way to do this?
Thanking You
Kindi
|
|
|
|
|
If you are only using NT-based systems, then SECURITY_DESCRIPTOR is the right way to do it. Just keep in mind that non-NT-based systems won't work with the security API.
To open a file and get a security descriptor for it, use the Windows API function CreateFile . As far as I know the MFC class CFile doesn't support security descriptors. It sounds like it would create a file, but it also opens files normally. Read MSDN for more.
This security descriptor also contains a structure which identifies the current owner (i.e. the one who has opened the file with write permission currently).
I am sorry that I cannot provide you a short source code snippet, I never used the security descriptor APIs.
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Hi
Thank you once agian..
GetSecurityInfo() fn gives a pointer to the owner SID which needs a valid handle of open file.
LookupAccountSid() returns the account name but needs system name and a pointer to the owner SID(can be obtained from GetSecurityInfo()) .
So what we need really is system name of the process which opened the file and a valid handle of the open file
CreateFile() returns INVALID_HANDLE_VALUE for an open file whose write permission is denied.
What we have is only a file name..I don't know how to get those two parameters
Do you have more suggestions like using a mutex or opening a socket??
Thanking You
Kindi
|
|
|
|
|
Hi,
I'm using C++ in VS.NET. I've created an dialogbased MFC application.
How can I display a jpeg-picture in a dialog (MFC)? I wan't to load the picture from a file stored on my HD or/and from a char* pointing at the picture data.
Can I use the Picture Control or something easy like that?
|
|
|
|
|
Good news and bad news:
the picture control is for bitmaps only. Sorry. However, you could find a custom control that displays JPEGS and attach it to a CStatic object in your dialog. I couldn't tell you where this control could be found, but i'm sure it's out there somewhere.
-- Steve
|
|
|
|
|
You would have to use someone else's control to do that, cximage (an article on code project) seems like the most popular way to do this.
|
|
|
|
|
Here's my problem.
I've got an array of integers that are sorted. I want to find the number of elements between a range defined by a pair of values - lower and higher.
Okay so they are sorted, so I can just use a binary search on each value of a range, to find the element - but I'm not expecting exact matches so the nearest will do.
Also where there are duplicates, I want to find the lowest, and highest in respect to which value of the range I'm looking for. I don't want when searching for the low end to land first time on the right value, and find that its 1 of 3 duplicates and I may not have included it.
I cannot see anything in STL (I'm using a vector for now - though of using a multiset but not really great difference).
I could write my own with 2 binary searches leaning to finding the lowest, and the highest, but these things are frought with nast bugs, and I was hoping that someone else has done it - well they have - you need it for a database by using the BETWEEN statement in SQL!!!
Thing is I cannot find an implementation on google.
Any ideas?
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Giles wrote:
Okay so they are sorted, so I can just use a binary search on each value of a range, to find the element - but I'm not expecting exact matches so the nearest will do.
Well, binary search has pretty good time complexity - O(log2 n).
Is your array so large you want one better than that?
As for the duplicates, I'm stumped.
Vikram.
-----------------------------
My site due for a massive update.
"Good lord you yanks are getting worse than a defensive VB developer at a C++ conference." - Paul Watson in the Lounge, 31 May 2003.
"Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design.
|
|
|
|
|
No its not a large array, its just that I need to extend the binary searches so that rather than returning yes - a value exists and this is one of them, I need here are all the values between this range.
e.g.
Position/Value
0 2
1 7
2 7
3 14
4 15
5 16
6 20
7 21
8 21
9 22
I want the positions between and including 7 and 20
Poitions 1-6
Notice that I must not accidently think position 2 is the first - is the same value and must be included.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
You can use either a linear or binary search, however and inject a count and then just return the count. If you are familiar with the STL, you can implement a map and then use the equal_range member function.
-Nick Parker
|
|
|
|
|
Yep, I'm familiar with STL. Thing is, with equal_range on a map or set, it returns the iterators representing the start and end positions in the binary tree for which a number would not break the sorting. Its similar but no quite the same I think.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
There's a global version of binary_search in <algorithm> that you can use with your vector.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
you can use lower_bound and upper_bound to find the range.
there's a global version which can even be used on TYPE *'s
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Is there a way to play a *.wav file wihtout having to link libraries to the project? Thanks
-KMaz
|
|
|
|
|
as far as i know only with linking a dll etc...
IceMatrix
|
|
|
|
|
I am using vc++ connect mysql server. How i going to add,delete and modify the data. I only know how to retrieve data.
siong
|
|
|
|
|
How are you connecting to the database (ADO, ODBC)? We need more information. To delete you can use an SQL query.
John
|
|
|
|
|
I am using mysql++ api to connect to mysql server.It is different from ado or odbc. Please help me!!! THanks....
|
|
|
|
|
Hi,
hope i've understood you right.
char sql[4000];
connection=mysql_real_connect(connection, host, user, passwd, db, 0, NULL, 0)
//add ist with insert into table values
sprintf(sql,"INSERT INTO %s VALUES (23 37 'test')",table); //e.g. i don't know your database
//modify ist with UPDATE and delete ist with DELETE FROM look api
mysql_query(connection, sql)
mysql_close(connection);
hope this helps
|
|
|
|
|
how to declare for the connection?
connection = mysql_real_connect();
siong
|
|
|
|
|
Oh sorry,
connection is a mysql-pointer;
MYSQL *connection;
|
|
|
|
|
Help me ,There still got big assertion error. What wrong with my code???
#define table "paises"
#define host "localhost"
#define user "admin"
#define passwd "123"
#define db "test"
char sql[4000];
CString d;
m_cboPais.GetLBText(m_cboPais.GetCurSel(),d);
//GetDlgItem(IDC_COMBO1)->GetWindowText(d);
// MYSQL mysql;
MYSQL *connection;
mysql_init(connection);
//mysql_options(connection,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
connection=mysql_real_connect(connection, host, user, passwd, db, 0, NULL, 0);
//add ist with insert into table values
sprintf(sql,"INSERT INTO %s VALUES (74 'dfdf' 0 'ey')",table); //e.g. i don't know your database
//modify ist with UPDATE and delete ist with DELETE FROM look api
mysql_query(connection, sql);
mysql_close(connection);
|
|
|
|
|
my fault,
your entries must be seperated be komma
sprintf(sql,"INSERT INTO %s VALUES (74, 'dfdf', 0 , 'ey')",table);
hope now ist works.
Heiko
|
|
|
|
|
Thank you very much!! U help me a lot!;P
I want to ask if u want to get the text u key in on combo box and then insert it into mysql database. How to get the text and then convert to vachar so that can insert into database?????
|
|
|
|