|
Thanks for the idea! Sort of like a debug output screen but written to a file. That it too simple!
And off the record, your other message was deleted because you were really listening to Iron Maiden again, right?
Thanks for the help!
Paul...
|
|
|
|
|
Nah, I just got the Hollywood Rocks box set, so I have no idea who I'm listening to from one moment to the next, but it's all good...
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If you can get your program 'started' then you should download the "Debugging Tools for Windows" form Microsoft's website. Install it. Read about running 'AdPlus to capture the 'crash' mode. Then look at the DMP file using WinDBG (have all the PDB files for your project handy) and you can probably determine exactly where and why your program crashes.
|
|
|
|
|
Problem:
I have difficulty in displaying Unicode string in Win32 console.
Test:
-Win32 Console is a character-mode application, not a byte-mode application. So even other documents said Win32 Console support Unicode, I found no sample or more details document than MSDN about this.
-I tried to used the FillConsoleOutputCharacter(Unicode development mode)
and found that the Win32 Screen Buffer is really a character-based buffer.
#include <wincon.h>
TCHAR c;
COORD crdSrc;
crdSrc.X = 0;
crdSrc.Y = 2;
for (c = 0x0000; c < 0xFFFF; c++)
{
...
FillConsoleOutputCharacter(hFile,c,sizeof(c),crdSrc,&dwConsole);
//Unicode mode: sizeof(c) = 1 character
}
The result in the output is always showing two character(???). But it can
show some following compound Unicode character: ㈪ ㈫ ㌘ ....
It make me confused now.
-I used "cmd /U" in command line. The pipe are Unicode but displaying is strill OEM.
Conclusion:
-I have a doubt that the Win32 Console Screen Buffer has one byte
per character(character-mode application). If it is actually that, it is
unable to show Unicode character in Win32 Console except some system Compound
Unicode Character.
Question:
-Can anyone help me to displaying Unicode string in Win32 Console?
-By the way, can you show me the way to read a handle(HANDLE) information. Reading STD_OUTPUT_HANDLE always causes violent access memory exception (is it secured pipe?).
Many thanks.
Le Tuan Anh
Mail to: anhlt@mt-it.com
|
|
|
|
|
Hello
How can I read another process of variable if I don`t know variable address?
If I know variable address,
I can do:
// readprocess.cpp
...
if( (string)pe.szExeFile =="A.exe" )
{
h=OpenProcess(PROCESS_ALL_ACCESS,TRUE,pe.th32ProcessID);
if(h!=NULL)
{
if(ReadProcessMemory(h,(LPCVOID)0x0012FED4,&tmp,4,&dwNumberOfBytesRead))
MessageBox(NULL,"ok","ok",NULL);
...
of course, get variable address(0x0012FED4) by other way;
//A.cpp
...
int a;
cout << &a << endl;
...
I want know how can get variable address by readprocess.cpp?
thanks!
|
|
|
|
|
I just new in visual c++ and have a copy of server and client source code. The result after I compile show Bytes recv: 21, but I want to change it so that I can send what I type. Can help me...Below is the client source code:
#include "stdafx.h"
#include "winsock2.h"
void main()
{
// Initialize Winsock.
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
{
printf("Error at WSAStartup()\n");
}
// Create a socket.
SOCKET m_socket;
m_socket = socket( AF_INET, SOCK_STREAM, 0 );
if ( m_socket == INVALID_SOCKET )
{
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
return;
}
// Connect to a server.
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( "127.0.0.1" );
clientService.sin_port = htons( 60000 );
if ( connect( m_socket, (SOCKADDR*) &clientService, sizeof(clientService) ) == SOCKET_ERROR)
{
printf( "Failed to connect.\n" );
WSACleanup();
return;
}
// Send and receive data.
long bytesSent;
long bytesRecv = SOCKET_ERROR;
char sendbuf[300] = "Client: Sending data.";
char recvbuf[300] = "";
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 );
printf( "Bytes Sent: %ld\n", bytesSent );
while( bytesRecv == SOCKET_ERROR )
{
bytesRecv = recv( m_socket, recvbuf, 300, 0 );
if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET )
{
printf( "Connection Closed.\n");
break;
}
if (bytesRecv < 0)
return;
printf( "Bytes Recv: %ld\n", bytesRecv );
}
return;
}
|
|
|
|
|
I'm at a loss why you keep pasting all of this code here. I'd also reiterate that it's obvious that you're using code when you have no idea what it does. Copy and paste without examining the code is no way to learn.
TTjen wrote:
char sendbuf[300] = "Client: Sending data.";
char recvbuf[300] = "";
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 );
As I said yesterday, it doesn't matter how big or small you make sendbuf, lstrlen will return the length of the string you assigned to it, which is 21. The rest of the variable just never gets sent, because it's beyond the null value which causes lstrlen to ( correctly ) stop counting. You can set this string to be any value you like, up to 300 characters, and it will send it and give you back it's length. A better approach would be to use a string class like std::string or, if you're using MFC, CString. Both give you access to the underlying char * without having to allocate any memory, or impose a length limit. then you can assign the text you type to this variable, and pass the buffer in to the send method.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Greetings All,
How does one initializes GDI+ in C++?
Thanks.
Sincerely,
Max Pastchenko
|
|
|
|
|
If you got to the appropriate section, I have a series of GDI+ articles, including one on how to get it working in VC6.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
certainly, I understand that a header file needs to be included but this is not quite what i asked. Lets say i want to start wowrking with colors once i inluded everything...
Sincerely,
Max Pastchenko
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingcolormemberstopic.asp\
What I really want to do is use a Dll that works with colors in GDI+, so I need to be able to send Color I want to use to that DLL from C++, if this makes sence.
Sincerely,
Max Pastchenko
|
|
|
|
|
That link leads to the Colors enum, I'm not sure that's visible in GDI+ using C++. If it is, did you write this dll ? What is it ? Why do you need to pass these values ? An enum is just a bunch of numbers, you should have no trouble passing it around.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
mpastchenko wrote:
Lets say i want to start wowrking with colors once i inluded everything...
Well, you didn't ask that. Read some tutorials, 'how do I work with colors' is a pretty broad question.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ok, sorry, i will be more specific.
My area of expertise in GDI+ in C++ environment is still lacking, i have been using it in C# without problems.
I have a DLL that contains some operations using GDI+, using System.Drawing.Color for some operation for example. One of the set properties in the DLL is supposed to Set this Color... it will use it then for further operation. For example, I need to pass color which needs to be skipped in bitmap comparison.
I did not write the DLL originaly, i added some modofications to it, so i know what it is supposed to do.
Sincerely,
Max Pastchenko
|
|
|
|
|
mpastchenko wrote:
I have a DLL that contains some operations using GDI+, using System.Drawing.Color for some operation for example. One of the set properties in the DLL is supposed to Set this Color... it will use it then for further operation. For example, I need to pass color which needs to be skipped in bitmap comparison.
Why do you need to pass a Color from the enum ? They are just a lookup to a red/green/blue value anyhow, and that's what your code will need to skip colors ( the R/G/B ). Why not pass a COLORREF ? Or even three bytes ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think passing one of the two will solve the problem. very good
Sincerely,
Max Pastchenko
|
|
|
|
|
I have been using Microsoft Visual C++ 6.0 for a MFC SDI project for some time.
Recently however, I have noticed that the Release Build of my executable gives an "Access Violation" error when the program is terminated. The Debug Build does not give any such problem.
Because I couldn't solve the problem, I loaded a backup of my project. The previously built executable ran and exited nicely, but when I recompiled the code and ran again, I recieved the same error.
The error occurs when the program is terminated (after the WM_DESTROY message is successfully processed, but before ExitInstance() or any of the Document/Frame/View objects have their destructor called.
The error is:
0xC00000005, Access Violation.
The assembly code at this point is something like
mov e-something dword ptr [eax]
or something like that (I am not at my pc now, it has no internet connection).
Note that information on the error is limited, because it only occurs in the Release Build.
If you have any idea what could be going on, or remember anywhere/anyone talking about something similar, PLS let me know.
|
|
|
|
|
Hamza5 wrote:
Note that information on the error is limited, because it only occurs in the Release Build.
This Would be helpful:-
www.codeproject.com/debug/survivereleasever.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks this article is great.
btw, there are two accidental spaces in front of the hyperlink, so it becomes "http:/ www." instead of "http:/www.".
Just mentioning that in case anyone else uses the link.
|
|
|
|
|
The problem can be caused by a non-initialized pointer ;
in debug version the pointer might be automatically
initialized to zero by the compiler, and in release
version, the compiler does not perform any automatic
init. So, when a delete is done on the pointer, it
crashes if the pointer is not null.
|
|
|
|
|
Thanks, I will review my code for that.
|
|
|
|
|
I posted this message to the MC++ forum a few days ago, but that place is a ghost town, so I thought I'd try here
I have a C# project that needs to use a C++ SDK, so I'm trying to write a MC++ dll to act between them. At first, this was fine, but the problem is, the SDK defines a number of function pointers for callbacks. The objects I pass through complain that they are __gc type instead of type, and the pointers themselves complain that they are not __stdcall, which I assume means that the .NET stuff has it's own calling convention. However, I'm not that knowledgable when it comes to dlls, and I sure have never used MC++ before. I tried putting __nogc at the head of the class, that fixed all my errors, but gave me a new one, telling me I can't do that. What's the best way for me to proceed here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry I can’t be of any help here, I’m still not .NET enabled.
But did you ever over come the issues you where facing with the other DLL you where working with?
If so what was the resolution?
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Not yet, I asked on a Microsoft forum, and someone gave me some advice, but not enough to get me through. I've not yet checked this morning to see if there's any more info there.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I am doing a project in win32. I have two dialog boxes running at the same time. At one point I want to close on of the dialog from the dialog proc of the other.
How do I get the handle of the dialog.
Pls help.
|
|
|
|
|