|
Mogaambo wrote: dude you haven't added +2 bytes
I know, I don't need to (I'm using SysAllocStringLen , not SysAllocStringByteLen ).
Mogaambo wrote: it is crashing as that of mine, but when i added +2 it is running fine
This is very strange.
Mogaambo wrote: so whenever i want allocate BSTR do i have 2 add + bytes
Nope. Even if your point about the crash is true (and is true, I know) this is a wrong conclusion.
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 made a silly error in my code, now fixed (please see again the posted snippet).
It should be OK now, the following test runs fine:
BSTR dest = SysAllocString(L"Hi ");
BSTR s1,s2,s3,s4;
s1 = SysAllocString(L"People, ");
s2 = SysAllocString(L"How do ");
s3 = SysAllocString(L"you ");
s4 = SysAllocString(L"do?");
HRESULT hr;
hr = StringAppend(&dest, s1);
hr = StringAppend(&dest, s2);
hr = StringAppend(&dest, s3);
hr = StringAppend(&dest, s4);
MessageBoxW(dest, L"Info");
SysFreeString(s1);
SysFreeString(s2);
SysFreeString(s3);
SysFreeString(s4);
SysFreeString(dest);
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]
|
|
|
|
|
If you run your code in debug mode , it crashes at line where you freeing the variable, but runs in release mode.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
My test works fine in DEBUG mode on my machine. What inputs are you providing?
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 recommend CComBSTR::AppendBSTR or _bstr_t::operator+
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
why are you modifying a const input parameter ie deleting
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: why are you modifying a const input parameter ie deleting Mad
if i do not free all the memory gets exhausted.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
If it had to be released from within the function, why does it come into the function as a const parameter? Isn't this strikingly flashy, yelling "Hey look! I'm the silliest!"?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
To free up the strings is correct and necessary, BUT NOT in a subroutine. Make it after the sub routine call.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
This my calling code tell me where do i free
BSTR GetNewRow()
{
value=GetLoggedInUser();
BSTR strComma=::SysAllocString(L",");
BSTR strNewLine=::SysAllocString(L"\n");
value=StringAppend(value,strComma);
value=StringAppend(value,strCategory);
value=StringAppend(value,strComma);
value=StringAppend(value,strItemName);
value=StringAppend(value,strComma);
value=StringAppend(value,strInstallDate);
value=StringAppend(value,strComma);
value=StringAppend(value,strVersion);
value=StringAppend(value,strComma);
value=StringAppend(value,strValue1);
value=StringAppend(value,strComma);
value=StringAppend(value,strValue2);
value=StringAppend(value,strComma);
value=StringAppend(value,strValue3);
value=StringAppend(value,strNewLine);
::SysFreeString(strComma);
::SysFreeString(strNewLine);
return value;
}
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Mogaambo wrote:
BSTR strComma=::SysAllocString(L",");
BSTR strNewLine=::SysAllocString(L"\n");
What about changing BSTR to _bstr_t ?
Defined in comutil.h
The MSDN link says that,
A _bstr_t object encapsulates the BSTR data type. The class manages resource allocation and deallocation through function calls to SysAllocString and SysFreeString and other BSTR APIs when appropriate. The _bstr_t class uses reference counting to avoid excessive overhead.
--++++++---
Use the += operator of _bstr_t to append characters to the end.
if value is also declared as a type of _bstr_t then code can be re-written as,
value += strComma;
value += strNewLine;
modified on Wednesday, May 13, 2009 5:12 AM
|
|
|
|
|
Thanks to all programming bees in helping me to solve my problems.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
this is very lame code. You better make at first the output string with CString (or otherwise) and at last ::SysAllocString()
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
What code you have written if you have to append the BSTR. It's a humble request from programmer to professional.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
I would first make a complete string in a CString or TCHAR-array and at last create a BSTR.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
i need a vc++ program for playing an audio file
|
|
|
|
|
Use PlaySound[^] API
PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);
|
|
|
|
|
Well, this forum is not exactly a software shop...
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]
|
|
|
|
|
|
How I get groups and the number of associated users in that group of a system.
Regards
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Check out NetGroupEnum and NetGroupGetUsers APIs.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Mogaambo wrote: How I get groups and the number of associated users in that group of a system.
Furthur to Superman's answer, use NetLocalGroupEnum[^] and NetLocalGroupGetMembers[^] to retrieve a list of the members of a particular local group in a local machine/system.
Mogaambo khush huvaa ?
|
|
|
|
|
Hi all,
i have SDI type application,and split it in two columns.
for one column i m using a Treeview and for another one i m using a FormView.
in toolbar two buttons functions override in Treeview class because they are related to treeview here i m inserting,deleting the tree items.
when i focus on formview and than click on those toolbar buttons than they are not working ,while when i have focus on TreeView and than click on those buttons than those are working perfectly.
please tell me how can i use as general.
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.
|
|
|
|
|
|
lek258 wrote: Creating ISO9660 Image File(URGENT PLEASE)
What variable type is "URGENT PLEASE"?
Maybe this works:
void Creating ISO9660 Image File(int URGENT PLEASE);
.
.
.
.
void Creating ISO9660 Image File(int URGENT PLEASE)
{
return;
}
|
|
|
|