|
Thanks. That to both of you. That works.
Problem is that I wanted to avoid a const size and instead use the variable size of m_pData (the original text). Is that possible?
Souldrift
|
|
|
|
|
Since m_pData is a string you can use string operations like strlen. Try this:
char *text = new char[strlen( m_pData ) + 1 ];
WCHAR *w = new WCHAR[strlen( m_pData ) + 1];
int erg=0;
strcpy(text, m_pData);
erg=MultiByteToWideChar(CP_ACP, 0, text, -1, w, strlen( text ));
erg=WideCharToMultiByte(CP_UTF8, 0, w, -1, text, wcslen( w ), 0, 0);
Just make sure that the strings are all NULL terminated!!
|
|
|
|
|
Hi I am using a ADO in my project. But when i compile my code i am getting the follwoing error.
error LNK2019: unresolved external symbol "long __cdecl _com_dispatch_method(struct IDispatch *,long,unsigned short,unsigned short,void *,wchar_t const *,...)" (?_com_dispatch_method@@YAJPAUIDispatch@@JGGPAXPB_WZZ) referenced in function "public: long __thiscall ConnectionEvents::InfoMessage(struct Error *,enum EventStatusEnum *,struct _Connection *)" (?InfoMessage@ConnectionEvents@@QAEJPAUError@@PAW4EventStatusEnum@@PAU_Connection@@@Z)
I have added this in my stdafx.cpp
#import "..\..\..\..\..\Microsoft\Redistribute\MSADO15.dll" no_namespace \
rename("Parameters","ADOParams") \
rename("Connection","ADOCon") \
rename("Parameter","ADOParam") \
rename("EOF", "adoEOF") \ implementation_only
and below code in my stdafx.h file
#import "..\..\..\..\..\Microsoft\Redistribute\MSADO15.dll" no_namespace \
rename("Parameters","ADOParams") \
rename("Connection","ADOCon") \
rename("Parameter","ADOParam") \
rename("EOF", "adoEOF") \ no_implementation
Please provide any comment i am not able to find out what is to be included to avoid this linking error.
|
|
|
|
|
Make sure you're linking against comsupp.lib (or some variant thereof - there's comsupp, comsuppd, comsuppw and comsuppwd) - that's where that symbol is defined. There is a #pragma in the #import process that specifies to link against that library, but it's possible, I guess, that doing the #import in stdafx negates the effect of the #pragma.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hallo, i have the following piece of code , when i try to delete the lpKeyPoint i get HEAP CORRUPTION DETECTED!
LPPOINT lpKeyPoint;
lpKeyPoint = (LPPOINT)new LPPOINT();
GetCaretPos((LPPOINT)lpKeyPoint);
if(lpKeyPoint)
{
delete lpKeyPoint;
lpKeyPoint = NULL;
}
How can i solve this problem?
Thanks.
|
|
|
|
|
susanne1 wrote: lpKeyPoint = (LPPOINT)new LPPOINT()
That should be:
lpKeyPoint = new POINT();
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks it worsk,but when i move the curosor up i get a worng value of y:
CPoint* ptrKeyPoint = new CPoint();
int nCursorLine = 0;
if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_LBUTTONDOWN))
{
if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_UP)||(pMsg->wParam == VK_DOWN) || (pMsg->message == WM_LBUTTONUP))
{
GetCaretPos((LPPOINT)ptrKeyPoint);
nCursorLine = ptrKeyPoint->y;
}
if(ptrKeyPoint)
{
delete ptrKeyPoint;
ptrKeyPoint = NULL;
}
}
|
|
|
|
|
susanne1 wrote: when i move the curosor up i get a worng value of y:
What do you mean (i.e. details please)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
when i press the arrow key up.
|
|
|
|
|
susanne1 wrote: when i press the arrow key up.
I think he can get that - what y value do you get ?
'g'
|
|
|
|
|
Garth J Lancaster wrote: I think he can get that
Well, it's Monday.............
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I try again: "How do you know that y value is wrong (please provide us details)?"
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
the cursor stands on the second line and ptrKeyPoint->y = 32;
it sohould be 16 instead of 32 because it starts with ptrKeyPoint->y = 0; (for the first line).
|
|
|
|
|
Ummmm - just don't use the heap, OK - this should work just as well:
CPoint keyPoint;
int nCursorLine = 0;
if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_LBUTTONDOWN))
{
if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_UP)||(pMsg->wParam == VK_DOWN) || (pMsg->message == WM_LBUTTONUP))
{
GetCaretPos(&keyPoint);
nCursorLine = keyPoint.y;
}
See what I've done there - I've declared and defined the CPoint item as a local, so it's on the stack. Then you don't need to worry about deallocation or anything. Much simpler.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
But corrupting the heap is much more fun.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hello everyone.
I'm very new to C++. I typically stay in .NET, but I can't do this in VB.
I'm writing an Explorer replacement shell and am working on capturing the system tray icon messages. I've been able to successfully create a window and can see the icon information via WM_COPYDATA messages in WndProc. I initially tried to forward those messages on to my VB.NET app using SendMessage. That didn't work so well. Everything I got was garbage.
That has me thinking of creating a C++ Win32 DLL to create window and watch the messages. Then, using a callback function, alert the host application (my VB app) of the new data.
One problem: I don't have the foggiest idea how to write callback functions! I'm new new new to C++. I'm having enough trouble wrapping my head around having more than one type of String!
Please if someone can help, I'd really appreciate it! I need to be able to send the host application a NOTIFYICONDATA struct.
Thanks,
Ray Phillips
LCARS x32 - A Star Trek Shell
|
|
|
|
|
Hi all,
I m using CeCreateProcess function to create process in mobile like this.
for(int i=0;i<25;i++)
{
PROCESS_INFORMATION pi;
test:
if (!CeCreateProcess(
L"Test.exe",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
NULL,
&pi))
{
goto test;
}
else
{
WaitForSingleObject( pi.hProcess, INFINITE );
CeCloseHandle( pi.hProcess);
CeCloseHandle( pi.hThread);
}
}
when i m creating process at multiple time so after some time its return false so i m using goto to call again the process,while the process not created successfully.
can u tell me please why its return false after sometime and when i call it again n again its looks like hanged but respond after some time and create the process successfully.
i think there is some memory problem.
so please tell me how can i release the previous memory before create a new process.
if possible please explain me with example.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Windows CE 1.0 through CE 5.0 and Windows Mobile is limited limited to 32 processes and your for-loop has 25 iterations. If there are other processes running at the same time you may be going over the 32 limit.
You can call CeGetLastError[^] to see why CeCreateProcess[^] is failing:
System Errors - Numerical Order[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Now i m noticed that diffreant geterror function return diffreant values.
HRESULT hr = CeGetLastError();
here hr=0x0000000e Not enough storage is available to complete this operation.
HRESULT hr1 = CeRapiGetError();
here hr1=S_OK
HRESULT hr2 = GetLastError();
here hr2=S_OK
please explain me i m confused.
which one is right.
please help me thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: which one is right.
please help me thanks in advance.
0xe == ERROR_OUTOFMEMORY so it looks like you are running out of memory on your mobile device.
Technically all of those function calls are correct. CeGetLastError [^]is returning the error code which was made through the RAPI function calls[^]. CeRapiGetError[^] is returning the last error inside the Remote API[^] which was none. GetLastError[^] is for returning the last error which was *not* called by an RAPI call.
Also keep in mind that these RAPI error functions are *not* thread-safe. So if your application creates multiple client RAPI threads each thread can overwrite the application error code.
Best Wishes,
-David Delaune
|
|
|
|
|
Please tell me how can i release memory of my mobile device.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: Please tell me how can i release memory of my mobile device.
All of the memory used by the process should be released once the application has exited. The process remains until all threads and all handles to the process and its threads are closed. I see that you are closing the handles.
For debugging purposes I would add a call to CeGlobalMemoryStatus[^] after each process creation so you can monitor the usage.
You can possibly call SHCloseApps[^] to have the device release additional memory.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: You can possibly call SHCloseApps[^] to have the device release additional memory.
for SHCloseApps function need to add aygshell.h or aygshell.lib,where i can find those files.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I m adding aygshell.h and after using SHCloseApps function but one error occured.
error LNK2019: unresolved external symbol _SHCloseApps referenced in function "public: void __thiscall CTestDlg::Test_Func(void)" (?Test_Func@CTestDlg@@QAEXXZ)
CTestDlg::Test_Func(void)
{
PROCESS_INFORMATION pi;
CString CMDdata;
MEMORYSTATUS MemStats;
MemStats.dwLength = sizeof(MEMORYSTATUS);
USES_CONVERSION;
if (!CeCreateProcess(
L"Test.exe",
T2CW((LPCTSTR)CMDdata),
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
NULL,
&pi))
{
CeGlobalMemoryStatus((LPMEMORYSTATUS) &MemStats);
if (MemStats.dwAvailPhys < MIN_MEMORY_TO_RUN)
{
if (!SHCloseApps(MIN_MEMORY_TO_RUN))
{
AfxMessageBox("Not free memory");
}
else
{
AfxMessageBox("free memory");
}
}
CeRapiUninit();
}
else
{
CeCloseHandle( pi.hProcess);
CeCloseHandle( pi.hThread);
}
}
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: error LNK2019: unresolved external symbol _SHCloseApps referenced in function "public: void __thiscall CTestDlg::Test_Func(void)" (?Test_Func@CTestDlg@@QAEXXZ)
The AYGShell Functions[^] require you to link with the aygshell library.
#pragma comment(lib, "aygshell.lib")
Best Wishes,
-David Delaune
|
|
|
|