|
I would do this:
char *pArrayLabel = NULL;
int size=12;
pArrayLabel = new char[size];
CString szLabel0 = "Januari";
strcpy(pArrayLabel,(char *)szLabel0.GetBuffer(szLabel0.GetLength()));
And when you pass it to the other function, pass it as "&pArrayLabel"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
once again, somebody is using CString::GetBuffer() when it's definitely not needed.
Call GetBuffer() only if you need to modify the CString object directly by writing inside its internal buffer. and this call to GetBuffer() requires a call to ReleaseBuffer() (which you don't do here).
if you only need to get the string contained within the CString, then you must use the cast operator (LPCTSTR) and that's it.
and for your problem, as that's been stated, you're assigning a NULL pointer.
modify your code into this.
ans at last, as i'm on it, please be careful with your variables names (generally, a variable starting with sz or psz is declared being a C-Style string)
const int iSize = 12;
TCHAR *pArrayLabel = ::new TCHAR[iSize];
CString strLabel = _T("Januari");
::_tcscpy_s(pArrayLabel[0], (LPCTSTR)szLabel0);
|
|
|
|
|
toxcct wrote: once again, somebody is using CString::GetBuffer() when it's definitely not needed.
Yeah, they should charge a toll $$$ to use CString::GetBuffer() and
CWnd::PreTranslateMessage() to help people consider alternative solutions
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The (LPCTSTR) cast is superfluous there too, because the compiler will automatically call it when it sees that the _tcscpy() parameter is an LPCTSTR .
|
|
|
|
|
You already got enough information from other replies.
If you are using visual studio 2005, consider using secured version of these CRT function.
Refer Security enhancement to CRT[^].
Prasad
MS MVP - VC++
|
|
|
|
|
Hi,
Pls help anyone know how to control the brightness of avi. file??
Thanks in advance.
|
|
|
|
|
I dont know my answer wasnt enough or you like to ask again!
|
|
|
|
|
can anyone correct for me this:
CString strText;
CString strSQL;
CDaoDatabase db;
db.Open("D:\\copyktt.mdb");
m_cedit.GetWindowText(strText);
strSQL.Format("INSERT INTO Table6 SELECT * FROM Table3 IN 'C:\\ktt.mdb' WHERE MyField = %s",strText);
db.Execute(strSQL);
|
|
|
|
|
Not without specific error messages, but it looks like you are missing VALUES in your insert text... You need to also be sure that the DB you are connecting to can handle a subquery in the syntax you use.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I think if you read an article (read,write Access file) that I think I answered to you that link its better.
After read values of first database /*select * from Table3 that I dont think its good statement you must use Select with a Where maybe you have 200,000 records */ you can use like this code for example
CDaoDatabase database;
CDaoRecordset recordset(&database);
CString lpszFile = "d:\\copyktt.mdb";
database.Create(lpszFile);
CString lpszSQL = "CREATE TABLE MYTable
(Field1 VARCHAR(4),Field2 VARCHAR(4),Field3 VARCHAR(4),Field4 VARCHAR(4),MarketState VARCHAR(4))";
database.Execute(lpszSQL);
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM MyTable",0);
database.Execute("INSERT INTO MyTable values('1','2','3','a','b')");
recordset.AddNew();
recordset.Update();
|
|
|
|
|
With what I understand about this macro, that its mandatory to use this
one for the following cases
<<
1)
All COM interface methods in "ATL using MFC" components should have this mac
ro.
2)
All COM eventsink methods in "ATL using MFC" components should have this mac
ro.
3)
Exported functions (or functions inside exported classes) of "Win32 dlls usi
ng MFC".
4)
Exported functions (or functions inside exported classes) of regular dlls us
ing shared MFC.
>>
Is this understanding correct??
For the 3rd case suppose I have a function inside a exported class, which ju
st uses some CString operations. Project as such uses MFC as shared dll. So
is it mandatory to use AFX_MANAGE_STATE at the beginning of such functions??
Am using VC 6.0 environment.
|
|
|
|
|
AFX_MANAGE_STATE mostly applies to anything in MFC that uses resources. Since MFC uses the app's
module handle when accessing resources, if you have an MFC extension DLL with its own resources
then the context needs to be switched in the DLL so the correct module handle is used by MFC.
CString is usable without having to use AFX_MANAGE_STATE.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
What message (WM_....) is fired by windows when user "stops a hardware device". How to trap this message through VC++.
(Go to USB Icon->right Click->click on "stop" button->Ok)
so how will i detect this through my Application,
My Problem is
handle of USB drive has been used by a service so when i am trying to safly remove this USB so one error is occuring i.e "The device 'generic volume' cannot be stopped righ now. Try stopping the device again later".
So anyone can help me out to resolve it.
Thanks in advance
RYK
|
|
|
|
|
So your problem is to write a usb detector app or unplug your usb from the computer?
--
=====
Arman
|
|
|
|
|
Yaa, i have USB detector but when i am stoping USB then it is not being detected if the handle of USb is being used by service
|
|
|
|
|
First, my apologies for posting this again - it went unanswered in the VB forum so I am trying with a bigger audience here....
I have a VB.NET 2005 application that makes calls to a C/C++ (VC6) DLL and I have that part working fine. The C/C++ DLL makes use of callback functions to let the VB application know of unsolicited events and that works as well (the functions are at least being called). The problem is I don't know the proper parameters to use (either the C++ or VB side) to get a byte array from C++ back to VB.
I have tried the following:
<br />
C++ side: <br />
BYTE bArray[] = { 11, 12, 13, 14, 15 };<br />
int len = 5;<br />
pfnCallback(bArray, len);<br />
<br />
VB side:<br />
CallbackHandler(ByVal data() as Byte, ByVal len as Integer)<br />
This resulted in the data array length of 1 and it only had the first value of the array no matter how big my array was.
Then I tried:
<br />
C++ side:<br />
SAFEARRAY *psa; <br />
(then properly created psa, and data copied in)<br />
pfnCallback(psa);<br />
(then properly destroy psa)<br />
<br />
VB side:<br />
CallbackHandler(ByVal data() as Byte)
This resulted in the data array length of 1 and it had the first element of C's SAFEARRAY in it (cDim). I could not see my data.
Am I barking up the wrong tree? Is what I want to do possible? I tried ByRef and got exception errors as it jumped from native code to managed code. For the short term, I made a string showing the hexadecimal values of the byte array and passed the string from the C/C++ library back up to VB; that works fine for now....
Thanks in advance,
Paul
|
|
|
|
|
have you tried using an IntPtr on the VB side ?
CallbackHandler(ByVal dataPtr as IntPtr, ByVal len as Integer)
then, Marshall the data into your VB objects...
|
|
|
|
|
Hello,
Read the article on MSDN: “How to Pass Arrays between Visual Basic and C”. http://support.microsoft.com/kb/207931
Some more links:
1. "Passing an array from VC++ DLL to VB", by Amol Kakhandki on Code project. http://www.codeproject.com/dll/ctovbarray_passing.asp
2. http://www.manbu.net/Lib/En/Class5/Sub7/1/23.asp
Regards
|
|
|
|
|
Thanks! Everyone has been a great help and I have the code working now.
|
|
|
|
|
Hi all,
How to add Serbian (cyrillic) language support to VC 6.0. It is not taking the language as it is. For example "Sačekajte malo..." message is not being displayed in as it is in VC 6.0 where as it is working in VC2005.
Please suggest me if any support required.
Thanks and Regards.
Kishore
|
|
|
|
|
Y K Kishore Kumar wrote: For example "Sačekajte malo..."
Not that I want to nitpick, but "Sačekajte malo..." is Serbian latin, not Serbian cyrillic.
As for your question - have you compiled with UNICODE defined?
|
|
|
|
|
Thanks for the reply.
Yes. i have complied the code with UNICODE but still it is not working.
|
|
|
|
|
I have execute https://192.168.1.100/ address so I am using shell execute command but I should display any alert message when Page cannot be displayed in the internet exploxer window
hand=ShellExecute(m_hWnd,"open","https://192.168.1.100/",NULL,NULL,SW_SHOWNORMAL);
S.Yamini
|
|
|
|
|
Oho, I'm afraid you cannot. ShellExecute merely launches the IE with some address and the other part of job is for EI itself. Whether the address is valid/in use/or smth else only does EI know.
--
=====
Arman
|
|
|
|
|