|
For unicode it is CONST WCHAR *
and for latin CONST CHAR *
i think now it is helpful for u.
long pointer to null terminated string
LPCSTR Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
This type is declared in WinNT.h as follows:
typedef __nullterminated CONST CHAR *LPCSTR;
LPCWSTR Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
This type is declared in WinNT.h as follows:
typedef CONST WCHAR *LPCWSTR;
LPCTSTR An LPCWSTR if UNICODE is defined, an LPCSTR otherwise.
This type is declared in WinNT.h as follows:
#ifdef UNICODE
typedef LPCWSTR LPCTSTR;
#else
typedef LPCSTR LPCTSTR;
#endif
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Thanks Shilpi,
I do not know it is const before, so I can not change the value of the string, right?
What means long pointer (for 1st letter L in LPCTSTR)?
regards,
George
|
|
|
|
|
<big>Acronym Definition</big>
LPCTSTR Long Pointer to a Constant null-Terminated String
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
Thanks shouvik,
Long pointer means? What is the difference between long pointer and a normal pointer?
regards,
George
|
|
|
|
|
The L bit is a historical hangover from 16 bit windows - it no longer has any extra meaning, but as the function prototypes for windows use it, it was kept on.
There used to be near and far pointers in the old days... sigh, segments....
Iain.
ps, I don't miss this old days, either!
|
|
|
|
|
Thanks Iain,
For 32-bit or 64-bit machine, I do not need to consider it, right?
regards,
George
|
|
|
|
|
Yeah of course. Pointers are very specifically address holders. The size of the pointers are dependent on the compiler too. While developeing 64Bit Applications the size of default pointer is 64.
Take this as a thunb rule. All sizeof are never constant-> they vary as per the compilers they are used in. If int is 2 byte in TurboC++ 3.0 it will be 4Bytes in VC++... Hope u can undestand my point.
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
Thanks shouvik,
I want to confirm your point that data type LPCTSTR works for both 32-bit and 64-bit transparently? Means developer could use the unified data type LPCTSTR without considering whether working on 32-bit or 64-bit platform safely?
regards,
George
|
|
|
|
|
That is really a novel idea. But upto my knowledge (which is bit of a dumb kind ) all 64 bit OS handle 32 bit data safely. I mean there is a back compatibility available which would allow safe usage without any data loss. I think they do padding and all to convert the 32 bit data to 64 bit.
If you really want to see if LPCTSTR works fine with both 64 bit and as well 32 bit transparently then develop an Appl in 32 bit compiler and then try executing it in 64 bit. I am a bit vague about further details regarding 32 bit and 64 bit compatibility issues.
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
It is ok. Thanks for your support for all the help you given to me on the question all the way.
regards,
George
|
|
|
|
|
George_George wrote: Thanks for your support for all the help you given to me on the question all the way.
That is the spirit @ CP and that is what makes my day happier while spending my day here. We all come back for a reason.
Actually one more thing to say is that LPCTSTR is strictly a Win32 stuff so please investigate it's memory implications then only proceed.In case you get to know some APIs which are translating 32 to 64 bit please share with us too.
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
|
Thanks, good link!
regards,
George
|
|
|
|
|
|
It means you have a bug in your code, why not try the debugger ?
|
|
|
|
|
thanks for reply sir
i use debugger and debugger shows this error in msgbox
and my code is as sir :
int i;
MYSQL *myDB;
MYSQL_RES *res;
MYSQL_ROW row;
CString user,pass,aqp;
if ((myDB = mysql_init((MYSQL*) 0)) &&
mysql_real_connect(myDB,"localhost","root",NULL,NULL,3306,NULL,NULL))
{
if ( mysql_select_db( myDB,"gourav") < 0 )
{
MessageBox("Can't select the database !\nTry later.");
goto exit_here;
}
else
{
MessageBox("Can't connect !\nPlease try later.") ;
goto exit_here;
}
}
GetDlgItemText(IDC_USER,user);
GetDlgItemText(IDC_PASS,pass);
if(mysql_query(myDB,"select * from login"))
res=mysql_store_result(myDB);
row = mysql_fetch_row(res);
MessageBox(row[0]);
exit_here:
mysql_close( myDB);
please sir help me to solve this one
thanks again
hi
|
|
|
|
|
No problem, does the debugger indicate which line might be cusing the access violation ?
Try changing the code a little as your error handling could be improved, I rewrote it like this, but obviously have not tested it, so give it a go and see if that improves anything.
int i;
MYSQL *myDB = NULL;
MYSQL_RES *res = NULL;
MYSQL_ROW row;
CString user,pass,aqp;
if((myDB = mysql_init((MYSQL*) 0)) &&
mysql_real_connect(myDB,"localhost","root",NULL,NULL,3306,NULL,NULL))
{
if(mysql_select_db( myDB,"gourav"))
{
GetDlgItemText(IDC_USER,user);
GetDlgItemText(IDC_PASS,pass);
if(mysql_query(myDB,"select * from login"))
{
res=mysql_store_result(myDB);
row = mysql_fetch_row(res);
MessageBox(row[0]);
}
}
else
MessageBox("Can't connect !\nPlease try later.") ;
mysql_close(myDB);
}
regards,
|
|
|
|
|
thanks sir
sir i try this one but it does not work
as same error at line
row = mysql_fetch_row(res);
before this same error at same line
thanks
hi
|
|
|
|
|
What is the value of 'res' when this line is executed, you'll need to strp through the code in your debugger.
res=mysql_store_result(myDB);
|
|
|
|
|
sir after debugging :
myDB shows this value 0x00ba4008
and res shows this 0x00000000
thanks.
hi
|
|
|
|
|
I suspect the call is failing, have you tried adding mysql_error() to see if you get an error.
Also, change this part of the code:
if(mysql_query(myDB,"select * from login"))
{
res=mysql_store_result(myDB);
row = mysql_fetch_row(res);
MessageBox(row[0]);
}
to this:
<pre
if(mysql_query(mydb,"select *="" from="" login"))
{
="" res="mysql_store_result(myDB);
" if(res)
="" {
="" row="mysql_fetch_row(res);
" if(row="" !="FALSE)
" messagebox(row[0]);
="" }
}<="" pre="">
|
|
|
|
|
yes sir i think u r right call is failing
becauze when debugger comes on if(res) it will show login window again
and this will stop debugger
but i dont know sir why this if(mysql_query(myDB,"select * from login"))
is not fetching result
[sir i use mysql 6.0 and VC++ 6.0(is there any problem Sir)]
hi
|
|
|
|
|
Are there any records in the database table ?
|
|
|
|
|
yes sir
i have database gourav , a table login and
this table has three fields user , password and id
and there are three records in this table
hi
|
|
|
|
|
What is the return value from the mysql_query(myDB,"select * from login")) function ?
Change it to this for a test:
int i = mysql_query(myDB,"select * from login");
What is the value of i ?
|
|
|
|