|
Hi Tim,
Happy to read that there is no problem to use such object in a global manner
I'm also sure that someting wrong is occuring in my application but I don't know where yet The GetSize() mmeber function return the right amount of elements but it crashes as soon as I try to debug what happen.
I know that I'll spend some time in debug But it must work
Cheers.
|
|
|
|
|
Hi there,
I've found the solution, there was effectively a memory trash problem in addition of a bad use of the CArray object.
1) I was passing a personal object by reference to a DLL, whose job is to fill some CString members. I just can say that YOU MUSN'T do direct changes to variable members but YOU MUST use accessors instead. Now, all my memory problems are solved
2) I was using GetAt(n) in order to make changes in elements but I wasn't modifying the element anymore Using [] overloaded operator works fine
|
|
|
|
|
Does anyone know how to clear all text from the macro tab in the Output Window from a DevStudio Add-in?
|
|
|
|
|
Hi,
does sombody know how to change the font of the binary files editor ?
the default font is not a fixed font, and it is hard to view.
Thanks
|
|
|
|
|
Hi;
I want to check the Internet connection and upload few data at my program startup to ensure coopyright. I can do the job using "IsRasConnected" if my program is running on a computer which has modem and internetconnection itself. But if the computer is connected to internet via a LAN using internet connection sharing (MS ICS) or NAT, I can not handle the job. help please....
|
|
|
|
|
What do you mean you cannot handle the job? How did you establish TCP/IP connection via modem? Under a LAN setup, one solution is to simply establish a connection via WSASocket() and WSAConnect().
Kuphryn
|
|
|
|
|
Use InternetCheckConnection exported from WININET.DLL
to perform a "ping" of the address in question.
|
|
|
|
|
Hi everyone
I trying to map WM_CHAR message But when focus is on the Buttons or Check Boxs Dialog Will be close .
How can I do To Map This Message
(I'm Sorry For My English )
Iman Ghasrfakhri
|
|
|
|
|
Hi can anyone help me in creating and sending the ICMP packet. please refer helping material websites or code for the problem. Important thing is that I want to access the ttl(hop count) of the icmp packet created.
Plz help me.
Reply me soon
|
|
|
|
|
Hi,
I have derived my class from CPropertyPage, I have included a Groupbox control. Inside that Groupbox I have included three Edit controls. I mapped CString variables as well as CONTROL variables for those Edit controls. Now when I am going to enable or disable those Edit control based on some values I am getting errors.
Anybody have any idea.
The Phantom is Tracking Bullets.
|
|
|
|
|
Instead of using the member for the CONTROL,
use GetDlgItem(IDD_EDIT1)->EnableWindow(0) to enable or disable the edit box.
|
|
|
|
|
What and where Asserts?
At first the controls must be created and have a handle than you dan disable them.
First step show the Page with enabled controls, than make a button "disable" with disabling and final change the disabling code to where you want it.
Try this @ home. (B&B)
|
|
|
|
|
I have already explained what I am getting.
There is still an assertion when I am setting the EditControl->EnableWindow(FALSE) values.
Please anybody has any idea how to do this, fist read the entire problem then answer please.
Thanks
The Phantom is Tracking Bullets.
|
|
|
|
|
Finally I have got the solution.
The answer to this problem is, to add an OnInitDialog(...) for the PropertyPage dervied class. And call the GetDlgItem(...)->EnableWindow(FALSE) in the OnInitDialog(...).
Thanks God for saving the day
The Phantom is Tracking the Bullets.
|
|
|
|
|
busisoft wrote:
Thanks God for saving the day
Not God, Microsoft. Easy mistake to make though
|
|
|
|
|
busisoft wrote:
I have already explained what I am getting.
There is still an assertion when I am setting the EditControl->EnableWindow(FALSE) values.
It seems like you are missing the point of ASSERTions. When your code ASSERTs it is usually because you are not using the MFC classes in the way in which they are intended.
I'm betting that the assertion that caused your code to crash was:
ASSERT(m_hWnd != NULL);
This line of code causes an Assertion when whichever window has not been created, so just by looking at this line of code in the debugger (when you get an Assertion, run your program in the debugger, then click on "Retry" - the debugger will jump to the Assertion in the MFC source (unless, of course you have your opwn ASSERTions in place - quite a good idea)) you will be able to see what is wrong.
Once you've debugged a few of these you will know what each one means and be able to fix the problem in a matter of minutes.
-Alex
|
|
|
|
|
I am in trouble. I am trying hard to send my tcp packet on the network but the packet is not going. I am using this strategy to do it.
1. create tcp packet using tcp structure.
2. Send the Packet using "Send to" method.
Posting the complete Code for Console application
#include "ip.h"
#define PORT 25
int main (void)
{
WSADATA wsd;
char datagram[4096];
int bOpt = 64;
if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)
{
printf("WSAStartup() failed: %d\n", GetLastError());
return -1;
}
// Create a raw socket
SOCKET s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (s == INVALID_SOCKET)
{
printf("WSASocket() failed: %d\n", WSAGetLastError());
return -1;
}
struct ipheader *iph = (struct ipheader *) datagram;
struct tcpheader *tcph = (struct tcpheader *) datagram + sizeof (struct ipheader);
struct sockaddr_in sin;
PS_HDR pseudo_header;
sin.sin_family = AF_INET;
sin.sin_port = htons (PORT);
sin.sin_addr.s_addr = inet_addr ("192.168.2.64");
memset (datagram, 0, 4096); /* zero out the buffer */
iph->ip_hl = 5;
iph->ip_v = 4;
iph->ip_tos = 0;
iph->ip_len = sizeof (struct ipheader) + sizeof (struct tcpheader);
iph->ip_id = 1;
iph->ip_off = 0;
iph->ip_ttl = 255;
iph->ip_p = 6;
iph->ip_sum = 0;
iph->ip_src = inet_addr ("192.168.2.61");
iph->ip_dst = sin.sin_addr.s_addr;
tcph->th_sport = htons (1234);
tcph->th_dport = htons (PORT);
tcph->th_seq = rand();
tcph->th_ack = 0;
tcph->th_x2 = 0;
tcph->th_off = 0;
tcph->th_flags = 2; // SYN
tcph->th_win = htons(65535);
tcph->th_sum = 0;
tcph->th_urp = 0;
// Build the Psuedo Header
pseudo_header.source_address = inet_addr ("192.168.2.61");
pseudo_header.dest_address = sin.sin_addr.s_addr;
pseudo_header.placeholder = 0;
pseudo_header.protocol = IPPROTO_TCP;
pseudo_header.tcp_length = htons(sizeof(tcpheader));
// Calculate Checksum
tcph->th_sum = checksum((unsigned short *)&pseudo_header, sizeof(pseudo_header));
iph->ip_sum = checksum((unsigned short *)&iph, sizeof(ipheader));
// ENABLE IPHDRINCL
if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&bOpt, sizeof(int)) == SOCKET_ERROR)
{
printf("setsockopt(IP_HDRINCL) failed: %d\n", WSAGetLastError());
return -1;
}
// Send The Packet
if (sendto(s, datagram, sizeof(datagram), 0, (SOCKADDR *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("sendto() failed: %d\n", WSAGetLastError());
return -1;
}
printf("message sent");
return 0;
}
/*********************** ip.h header file *************************/
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <stdio.h>
struct tcpheader {
unsigned short int th_sport;
unsigned short int th_dport;
unsigned int th_seq;
unsigned int th_ack;
unsigned char th_x2:4, th_off:4;
unsigned char th_flags;
unsigned short int th_win;
unsigned short int th_sum;
unsigned short int th_urp;
}; /* total tcp header length: 20 bytes (=160 bits) */
struct ipheader {
unsigned char ip_hl:4, ip_v:4; /* this means that each member is 4 bits */
unsigned char ip_tos;
unsigned short int ip_len;
unsigned short int ip_id;
unsigned short int ip_off;
unsigned char ip_ttl;
unsigned char ip_p;
unsigned short int ip_sum;
unsigned int ip_src;
unsigned int ip_dst;
}; /* total ip header length: 20 bytes (=160 bits) */
// Psuedo Header
typedef struct ps_hdr
{
unsigned int source_address; // Source Address => 4 Bytes
unsigned int dest_address; // Destination Address => 4 Bytes
unsigned char placeholder; // Place Holder => 1 Bytes
unsigned char protocol; // Protocol => 1 Bytes
unsigned short tcp_length; // TCP Length => + 2 Bytes
// = 12 Bytes
struct tcpheader tcp;
}PS_HDR;
// IP/TCP/UDP Checksum Function
USHORT checksum(USHORT *buffer, int size)
{
unsigned long cksum=0;
while (size > 1)
{
cksum += *buffer++;
size -= sizeof(USHORT);
}
if (size)
{
cksum += *(UCHAR*)buffer;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >>16);
return (USHORT)(~cksum);
}
/*********************** ip.h header file *************************/
//The code is executing perfectly but the packet does not reach its destination.
//plz help me
Reply me soon
|
|
|
|
|
Hi ,
I want to do an Encyption Program. I got a sample code from MSDN site. When I am compling that Program some varibles & Functions showing error as Undeclared identifier. HCRYPTPROV, HCRYPTKEY, CryptAcquireContext() etc....
I have already included the "Wincypt.h"
Can anyone help me to sove this error?
Thanks in Advance
SAN
|
|
|
|
|
Hi ,
I want to do an Encyption Progrma. I got a sample code from MSDN site. When I am compling that Program some varibles & Functions showing error as Undeclared identifier. HCRYPTPROV, HCRYPTKEY, CryptAcquireContext() etc....
I have included the "Wincypt.h"
Can anyone help me to sove this error?
Thanks in Advance
SAN
|
|
|
|
|
Try this:
#define _WIN32_WINNT 0x0500
--
karl
|
|
|
|
|
Hey everyone!
I put myself a string class in C++ together, and now I want an easy way to initialize it with some string. One thing is the constructor that takes a LPCTSTR-type as an argument, in the fashion of cString (LPCTSTR somestring). Now I'd like to be able to do something like:
cString *bunchachars = new cString ();
bunchachars = "Now here comes the filling";
I did a little of research on the internet, and two terms I came across (that I could imagine being applied here) were the = operand and the cast-constructor. Can anyone give a little detail on this, or just tip me into the right direction?
cheers
tilli
|
|
|
|
|
tilli again wrote:
Can anyone give a little detail on this, or just tip me into the right direction?
You should REALLY read the code of the std::string class (and its definition http://www.sgi.com/tech/stl/)as well as the CString -code from MFC.
There is no point in reinventing the wheel - at least interface-wise.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Well, I'm writing my own Win32 API wrapper, just for not having to use MFC (personal choice and just a fun thing). I don't wanna end up having to use any of these huge libraries. Still, it might make sense to see how it was done in the std::string class, thanks for the hint!
|
|
|
|
|
From the looks of it, you're coming from some garbage-collected language such as Java or C#. In C++ you can allocate objects on the stack just like ints and longs. So you can do this:
cString str;
str = "whatever";
or
cString str = "whatever";
cString str("whatever");
If you have a pointer, like in your example, you must "dereference" it:
cString *bunchachars = new cString;
*bunchachars = "Now here comes the filling";
Regards,
Alvaro
There are no stupid questions, but there are a lot of inquisitive idiots. -- despair.com
|
|
|
|
|
I've successfully use GetCursorPos() and WindowFromPoint() to get the window handle. Then I use SendMessage() to send "WM_COPY" to that application, so that I can copy the selected text to the clipboard for my application. This method success in notepad. But when I try this method in openoffice, it failed.
Openoffice seems doesn't accept the message "WM_COPY". Does anyone know how can I get the selected text from openoffice? Thanks a lot.
|
|
|
|