|
DavidCrow wrote:
Where's the call to ReleaseBuffer()?
DavidCrow,
i'm pretty sure the problem faced is not due the missing call to ReleaseBuffer(). Coz "ReleaseBuffer method releases a buffer allocated by GetBuffer."
Even if Ali_quadin had to call ReleaseBuffer() it should be after the line " CString strINIFilePath = lpBuffer;" but by this time the strINIFilePath is already memcpyed from lpBuffer and it is supposed to have the copy of it.
Pls correct me if i'm wrong.
suhredayan There is no spoon.
|
|
|
|
|
suhredayan® wrote:
i'm pretty sure the problem faced is not due the missing call to ReleaseBuffer().
Empirical testing would be the only way to know for sure. Given that ReleaseBuffer() must be called before any other CString method, I stand by my claim.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
Given that ReleaseBuffer() must be called before any other CString method, I stand by my claim.
But Ali_quaidian dosen't call any of the temp objects method, after temp.getbuffer(), so i'm finding difficult to understand the revelence of ReleaseBuffer() in this problem.
suhredayan There is no spoon.
|
|
|
|
|
suhredayan® wrote:
...i'm finding difficult to understand the revelence of ReleaseBuffer() in this problem.
Sorry, my bad.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Or you could do:
TCHAR currDir [MAX_PATH];
DWORD dwRet = ::GetCurrentDirectory (MAX_PATH - 1, currDir);
ASSERT (dwRet != 0);
CString strCurrDir = currDir; /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
You could just use strINIFilePath directly:
CString strINIFilePath;
GetCurrentDirectory(MAX_PATH, strINIFilePath.GetBuffer(MAX_PATH));
strINIFilePath.ReleaseBuffer();
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
hi,everyone.
I am learining how to use GDI+.
I do the following things in my programme:
1. Include gdiplus.h
2. Add the gdiplus.lib in Project->Settings->Link-> Object/library modules .
3. Add "using namespace Gdiplus" at the beginning of the source code.
4. Initialize GDI+ using GdiplusStartup.
but I got a lot of errors:
Compiling...
StdAfx.cpp
f:\microsoft visual studio\myprojects\trygdipp\stdafx.h(22) : error C2871: 'GdiPlus' : does not exist or is not a namespace
c:\program files\microsoft sdk\include\gdiplusinit.h(32) : error C2065: 'ULONG_PTR' : undeclared identifier
c:\program files\microsoft sdk\include\gdiplusinit.h(32) : error C2065: 'token' : undeclared identifier
c:\program files\microsoft sdk\include\gdiplusinit.h(32) : error C2165: 'left-side modifier' : cannot modify pointers to data
c:\program files\microsoft sdk\include\gdiplusinit.h(32) : error C2071: 'NotificationHookProc' : illegal storage class
c:\program files\microsoft sdk\include\gdiplusinit.h(33) : error C2146: syntax error : missing ')' before identifier 'token'
c:\program files\microsoft sdk\include\gdiplusinit.h(33) : error C2165: 'left-side modifier' : cannot modify pointers to data
c:\program files\microsoft sdk\include\gdiplusinit.h(33) : error C2071: 'NotificationUnhookProc' : illegal storage class
c:\program files\microsoft sdk\include\gdiplusinit.h(33) : error C2059: syntax error : ')'
c:\program files\microsoft sdk\include\gdiplusinit.h(86) : error C2059: syntax error : 'const'
c:\program files\microsoft sdk\include\gdiplusinit.h(95) : error C2146: syntax error : missing ')' before identifier 'token'
c:\program files\microsoft sdk\include\gdiplusinit.h(95) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdk\include\gdiplusinit.h(95) : error C2182: 'GdiplusShutdown' : illegal use of type 'void'
c:\program files\microsoft sdk\include\gdiplusinit.h(95) : error C2059: syntax error : ')'
c:\program files\microsoft sdk\include\gdiplusflat.h(2639) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdk\include\gdiplusflat.h(2639) : error C2440: 'initializing' : cannot convert from 'int' to 'enum Gdiplus::Status'
Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
c:\program files\microsoft sdk\include\gdiplusflat.h(2644) : error C2146: syntax error : missing ')' before identifier 'token'
c:\program files\microsoft sdk\include\gdiplusflat.h(2644) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft sdk\include\gdiplusflat.h(2644) : error C2182: 'GdiplusNotificationUnhook' : illegal use of type 'void'
c:\program files\microsoft sdk\include\gdiplusflat.h(2644) : error C2059: syntax error : ')'
Error executing cl.exe.
TryGdipp.exe - 17 error(s), 3 warning(s)
So I includeed
typedef unsigned __int64 ULONG_PTR;
in stdafx.h and there left one error:
f:\microsoft visual studio\myprojects\trygdipp\stdafx.h(22) : error C2871: 'GdiPlus' : does not exist or is not a namespace
Error executing cl.exe.
Can someone tell me how to solve the problem?
Thank you!
|
|
|
|
|
using namespace Gdiplus; // note the lower case 'p'
"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! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I have included using namespace Gdiplus; in the stdafx.h file,
but now there comes another error....
Linking...
LINK : fatal error LNK1104: cannot open file "C:\Program.obj"
Error executing link.exe.
TryGdipp.exe - 1 error(s), 0 warning(s)
what's that about???
thank you very much!
|
|
|
|
|
|
|
Whilst I can get all the processes running on my workstation and hence a handle to the process, and the .EXE name. How can I get the commandline arguments for that process ?
I'm trying to write an app so that I can identify the processes better, as we have several wscript.exe scripts run at login time, but some need to be killed by the user after login, any help would be gratefully received.
|
|
|
|
|
|
This is just what I was looking for, many thanks it is much appreciated.
|
|
|
|
|
|
I have made deskband object. How to programmatically show and hide it?
If that was explorer bar, i'd use IWebBrowser2::ShowBrowserBar.
Thank you!
|
|
|
|
|
Did you ever get an answer?
|
|
|
|
|
Just for learning purposes, I'm trying to implement the code Mark Petrik Sosa put in a message at 6:47 14 Apr '05 in a reply to 'Send Messages to Other Windows' (4:34 14 Apr '05).
<br />
HWND hNotepad = FindWindowEx(0, 0, "Notepad", 0);<br />
if(hNotepad)<br />
SendMessage(hNotepad, WM_SETTEXT, 0, (LPARAM) "Hah, I found you!");<br />
else<br />
MessageBox(0, "Couldn't find notepad.", "Darn", MB_OK);<br />
<br />
When I compile, I get:<br />
error C2440: 'initializing' : cannot convert from 'CWnd*' to 'HWND'<br />
error C2660: 'CWnd::SendMessageA': function does not take 4 arguments<br />
<br />
If I change to <br />
CWnd* hNotepad = ...<br />
and then<br />
SendMessage(hNotePad->m_hWnd, ...<br />
I still get the C2660 error.<br />
<br />
I also get<br />
'CWnd::MessageBoxA': function does not take 4 arguments<br />
I can see that SendMessage has 2 prototypes - one takes 3 arguments and looks like it's for the cases where you do not need to specify a handle.
Would appreciate any direction on how to fix the code and/or explanations to help me understand the mechanisms involved here.
|
|
|
|
|
::SendMessage(hNotepad, WM_SETTEXT, 0, (LPARAM) "Hah, I found you!");
and
::MessageBox(0, "Couldn't find notepad.", "Darn", MB_OK); or MessageBox("Couldn't find notepad.", "Darn", MB_OK);
|
|
|
|
|
Thanks.
It now compiles and executes properly.
If you have another minute though, I still get the error 'initializing': cannot convert from CWnd* to HWND unless I declare hNotepad as CWnd*. Then when I do that I have to use hNotepad->m_hWnd, which makes sense. Is there some include file I need such that I can declare hNotepad as HWND and then use it as you and Mark used it (i.e., without the ->m_hWnd)?
|
|
|
|
|
If you dereference your pointer ( *hNotepad ), then operator HWND should come to the rescue.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I haven't found the secret yet. If I still declare with CWnd
<br />
CWnd* hNotepad = FindWindowEx(...<br />
then I can use
<br />
::SendMessage(*hNotePad, ...<br />
But if I declare with
<br />
HWND hNotepad = FindWindowEx(...<br />
or
<br />
HWND *hNotepad = FindWindowEx(...<br />
I still get the error message
'initializing' cannot convert from CWnd to HWND
Is it maybe because the 2003 compiler is more strict than compilers in the past? I don't have much experience/history with Visual C++.
|
|
|
|
|
Has anyone ever tried (and managed) passing the IP number of the remote machine instead of the machine name in the remote filename url?
I can successfully create a BITS job when i specify the remote file using the machine name in the url, but somehow the job cannot be created when i specify the ip number of the same machine in the url instead of the name. Any ideas anyone?
(If it can help, the remote machine ip is dhcp-assigned, but i don't think this can create a conflict)
|
|
|
|
|
Hi,
How can I get the DWORD or Binary Value using RegQueryValueEx function?
Cheers,
Thanks.
|
|
|
|
|
<code>DWORD dKeyValue;
DWORD dType;
DWORD dSize=sizeof(DWORD);
RegQueryValueEx( hKey, "KeyName", NULL, &dType,
reinterpret_cast<LPBYTE>(&dKeyValue), &dSize)</code>
suhredayan
|
|
|
|