|
as title.
Can I do this?
WCHAR *strPtr1 = new WCHAR[10];
strPtr1 = L"123456";
LPWSTR strPtr2 = strPtr1;
if I do not delete strPtr1 and strPtr2 before redirect strPtr2 points to the other place, will it cause memory leakage?
e.g
strPtr2 = L"abcdef";
And there is any difference between
WCHAR *strPtr1 = new WCHAR[10];
and
LPWSTR *strPtr1 = new wchar_t[10];
?
Thanks
|
|
|
|
|
WCHAR *strPtr1 = new WCHAR[10];
strPtr1 = L"123456";
LPWSTR strPtr2 = strPtr1; Both pointers now point to the same array of 10 WCHAR 's. If you delete either pointer, the memory is returned to the heap, and neither pointer may be used to access the memory.
LPWSTR *strPtr1 = new wchar_t[10]; This will not compile. LPWSTR , which can be read as Long Pointer to Wide STRing, is defined as
typedef WCHAR FAR * LPWSTR; in the Windows headers. If you had written
LPWSTR strPtr1 = new wchar_t[10]; instead, this would work. Notice I removed the asterisk between LPWSTR and strPtr1 . LPWSTR is already a pointer. WCHAR and wchar_t are essentially equivalent, in that they refer to a 16 bit value used as a wide character.
Software Zen: delete this;
|
|
|
|
|
That's mean it is no difference between LPWSTR and WCHAR*?
|
|
|
|
|
The LP stuff is a throwback to the old Win16 days.
In Win16, you have two types of pointers, NEAR and FAR. A near pointer is only 16 bits wide and can only access 65k of memory. A far pointer is 32 bits wide and can access many megs of memory. (The upper and lower 16 bits of a FAR pointer usually overlap a few bits).
So, "FAR WCHAR *" in WIN32 is the same thing as "WCHAR *" since FAR doesn't do anything anymore. And since WCHAR is the same (or mostly the same) as wchar_t, then LPWSTR is the same as "wchar_t *". Also, LPCWSTR is the same as "const wchar_t *".
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
One can set a bookmark in the VC6 IDE, Alt-F2,
bookmark dialog. Such a bookmark seems to be
stable across projects. I can select all and
delete all. But, if I open an old project
then return to my current project via the
most recent project list -- say to look at
a backup copy or some older code -- then
all those old bookmarks are returned. I
have to clean it up again. Perhaps a good
feature; but not what I want!
I have searched the registry. I have deleted
.bsc files. But I don't find a way to clean
up my bookmark "history".
Can someone tell me a way to get rid of ALL
the old bookmarks. I want a clean slate.
NO bookmarks in any project (and I have lots
of old stuff laying about )
WedgeSoft
|
|
|
|
|
Dear All,
I am developing an application in VC++ Version 6.0 for Windows
2000/XP and want to have following functionality in it :
"Whenever the user right clicks on any drive, a menu is opened with
various options,and one of them is to Format the drive.I want to
replace the format window dialog box with my own custom dialog box."
So, is it possible to replace the windows format dialog box(which
comes when we try formatting a drive using right click) with our own
format box???
Is this functionality of windows is in form of a dll ? If it is so,
then i suppose we can replace that dll. (A case i know is that like
gina.dll contains the window that appears upon ctrl+alt+del and we can
replace this dll with our own). But i am not very clear on this issue.
Please suggest!
Regards,
Rohit
|
|
|
|
|
The format dlg is displayed by the API SHFormatDrive() , so in order to change that you'll need to hook that API. This is more complex than a simple shell extension.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Dear all,
Question - I want to change the entry point of my program to some "MyFunction". I know that, it can be done by taking project Settings, Link tab, then Input section and specify the entry point.
But my requirement is to done it by code using any #pragma or any other preprocessor like that. Please help me.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
#pragma comment(linker, /entry:"MyFunction")
Bikram Singh
I believe we should all pay our tax with a smile. I tried - but they wanted cash.
|
|
|
|
|
Dear bikram,
Thanks a lot.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Hello Sir,
really i tried that->
#pragma comment(linker, /entry:"MyFunction")
but sad i didn't able to work it out.
pls help me in this.
thanks
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Unfortunately, that doesn't work. According to the MSDN, you can only use the /DEFAULTLIB, /EXPORT, /MERGE, /INCLUDE, and /SECTION linker options in a #pragma comment(linker,...) .
Software Zen: delete this;
|
|
|
|
|
hello i am working on a little information database for a game a friend of mine plays well everything is working smoothly but , i have been trying to make it so that when they get new information they can add it to a combobox through an editbox .. and the combobox will hold the information in the dropdown .. but i cant seem to get anything..
thank you for your time
|
|
|
|
|
nm i finaly got it needs a little tweaking but will have it shortly
thank you for your time
"Effort within the mind further limits the mind, because effort implies struggle towards a goal and when you have a goal, a purpose, an end in view, you have placed a limit on the mind"
|
|
|
|
|
hello,
i want to find the cpu usage time of a process.
i tried to use NtQuerySystemInformation in
ntdll.dll.
the syntax..
NTSTATUS NtQuerySystemInformation(
SYSTEM_INFORMATION_CLASS SystemInformationClass,
PVOID SystemInformation,
ULONG SystemInformationLength,
PULONG ReturnLength
);
i declared a pointer to function (the above func)
and tried to call it dynamically by using
LoadLibrary & GetProcAddress....
but, the program is giving a compilation error:
saying that -
NTSTATUS & SYSTEM_INFORMATION_CLASS are undeclared identifiers...
can anyone please help...
thank you..
|
|
|
|
|
|
I'm working on Shell Programming..
What I wanna know is how to get system icon index by using IShellFolder interface..
When I worked with SHGetFileInfo, I could get the index by reteiving iIcon value in SHFILEINFO structure which is retured from SHGetFileInfo function..
but even though I got the IExtractIcon pointer from IShellFolder interface,
I couldn't find any functions or flags in IExtractIcon interface..
Does anyone know info about this.?
ps. sorry for my poor english..
Thanks in advance..
|
|
|
|
|
long StrFind( LPCTSTR lpExpression, ULONG nStart, LPCTSTR lpFind )
{
CONST ULONG lpFindLength = strlen( lpFind );
ULONG nPos = nStart;
TCHAR lpTemp[lpFindLength+1];
...
ok, i thought using CONST for lpFindLength
would stop that annoying "expected constant expression" error, but i guess not,
so does anyone know how to solve this problem, or am i just going to have define lpTemp like this?
TCHAR lpTemp[512];
|
|
|
|
|
TCHAR lpTemp = new TCHAR[lpFindLength + 1]; Just be sure to delete[] it when you are done.
The compiler can not reserve stack space for your array if it does not know at compile time how big your array is, that is why you get the error.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
i have a project which being planed to pretent API HOOK by other programs.
for instance. I want to use the WINAPI OpenProcess function. But it is easily to Hook by other program by GetModulHandle("Kernel32.dll")...........
so i changed the file name of the "Kernel32.dll" to "myprocess.dll" and put it in my project and i want to use the OpenProcess function in "myprocess.dll" but not in the "Kernel32.dll" anymore
anyone who knows how to do it?
many thanks
|
|
|
|
|
I've found a lot of documentation regarding how to add a sink interface for ActiveX controls. However, I'm having difficulty finding a good definition of what exactly a sink interface is.
I'm a beginning programmer. I'm currently reviewing some technical documentation at work and I need to have a clear understanding of what a sink interface is.
Thanks in advance!
Ian
|
|
|
|
|
Can someone send me some sample code to display uninstalled fonts? Some thing like the 'The Font Thing'
Also, how to dump the displayed font to an image file (jpg/gif/bmp) (displayed text in an image file)
Thanks
pgeorge64@yahoo.com
|
|
|
|
|
Temporarily load the font using AddFontResourceEx(). The font is now installed in the system for the current session. The next time the system starts, this font wont be loaded automatically. You can also use the RemoveFontResourceEx() function to unload a font.
Bikram Singh
I believe we should all pay our tax with a smile. I tried - but they wanted cash.
|
|
|
|
|
How can i change the Color of text being displayed in a CStatic control ?
|
|
|
|
|
Hey
Can we Creat Threads in DLL???
Shailesh
|
|
|
|