|
GflPower wrote:
how to install windows NT service int cmd ?
use CreateService api
"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
|
|
|
|
|
Read this[^] guide.
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
I recently started exploring using an SDI interface for this app I'm trying to write and I'm currently filling out the source code to do it (which should be complicated). I started the project from the AppWizard like almost all of my apps do. It asked me for a default file extension but I didn't give one not knowing what I'd want and figured I could set it later and here I am, ready to set a default extension but I can't seem to find it. I've tried searching help files and searching for the text "ext" but nothing shows up. Does the system default to All Files since I didn't offer up an extension and I need to add in something somewhere to set the extension?
Also, how can I change what shows up in the child window? I just get a big white area. I want to take out that white area and place controls on my own in there through source code.
|
|
|
|
|
All you need do is go to Resource-->String table. There you can find entry for IDR_MAINFRAME. You can get help to fill out IDR_MAINFRAME through google.
Other see the following example.
IDR_MAINFRAME has to be set like this.
sample\n\nSample\nSample Files (*.dat)\n.dat\nSample.Document\nSample Document
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
What should i do to make the big dialog bar displayable with different resolution.
The problem i am currently facing is that the dialog bar cannot be fully displayed with low resolution even when maximized.
How to make it compatible with different resolution?
Thanks in advance...
|
|
|
|
|
I have a server and client source code and I not very understand the send and receive part of the program. After I execute the program, it show Bytes send: 21. I don't know why it is 21. Can somebody tell me?
Below is the code for the server:
#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;
}
// Bind the socket.
sockaddr_in service;
service.sin_family = AF_INET;
service.sin_addr.s_addr = inet_addr( "127.0.0.1" );
service.sin_port = htons( 60000 );
if ( bind( m_socket, (SOCKADDR*) &service, sizeof(service) ) == SOCKET_ERROR )
{
printf( "bind() failed.\n" );
closesocket(m_socket);
return;
}
// Listen on the socket.
if ( listen( m_socket, 1 ) == SOCKET_ERROR )
{
printf( "Error listening on socket.\n");
}
// Accept connections.
SOCKET AcceptSocket;
printf( "Waiting for a client to connect...\n" );
while (1)
{
AcceptSocket = SOCKET_ERROR;
while ( AcceptSocket == SOCKET_ERROR )
{
AcceptSocket = accept( m_socket, NULL, NULL );
}
printf( "Client Connected.\n");
m_socket = AcceptSocket;
break;
}
// Send and receive data.
int bytesSent;
int bytesRecv = SOCKET_ERROR;
char sendbuf[32] = "Server: Sending Data.";
char recvbuf[32] = "";
bytesRecv = recv( m_socket, recvbuf, 32, 0 );
printf( "Bytes Recv: %ld\n", bytesRecv );
bytesSent = send( m_socket, sendbuf, strlen(sendbuf), 0 );
printf( "Bytes Sent: %ld\n", bytesSent );
return;
}
|
|
|
|
|
( sorry, I had two windows open, typed in the wrong one ).
Because the string you're passing in is that length, and you're passing in the result of strlen, which gives you that value.
I get the feeling you copied and pasted this from somewhere and have no real idea what it does, or even how C++ string handling works. If this is true, stop worrying about what you can cut and paste, and concentrate on learning the fundamentals of the language.
Christian Graus - Microsoft MVP - C++
-- modified at 22:04 Monday 5th September, 2005
|
|
|
|
|
Christian Graus wrote:
Because the string you're passing in is that length, and you're passing in the result of strlen, which gives you that value.
The length of the string he is sending is 21 (32 is the size of the array), I think that's why he is confsued when send returns 32?
-- modified at 7:19 Tuesday 6th September, 2005
oh forget it, he really wonders why the string length is 21.
|
|
|
|
|
Here length of the sendbuf is 21. send() function returns the number of bytes it is sended. thats why the value 21. recv() function returns the number of bytes received.
|
|
|
|
|
This is a simple socket communication program. here send() functions sends the data. and it retuns the number of bytes sended. in this length of the string sendbuf is 21. recv() function returns number of bytes received.
|
|
|
|
|
hello, i was wondering if there is an equivalent of the c# feature "properties" in c++. i.e., the client sees it as a variable, but methods are called to access it. You should understand from this c# sample:
<br />
namespace MyApp {<br />
public class TestClass {<br />
private int _item;<br />
<br />
TestClass(int tmp) {<br />
_item = tmp;<br />
}<br />
<br />
public int data {<br />
get {return _item;}<br />
set {_item = value;}
}<br />
<br />
static void Main() {<br />
TestClass x = new TestClass(17);<br />
int res = TestClass.data;
<br />
TestClass.data = 42;<br />
res = TestClass.data;
}<br />
}<br />
}
any equivalient in c++ ?
|
|
|
|
|
No. Properties do not exist in C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
visual studio only supports monochrome, 16-colors and 256-colors icons. how can I attach a 32-bit insolved icon?
|
|
|
|
|
|
|
i guess you are using Visual Studio 6.
you can import into your resources your 32-bits icon but won't be able to open it within VS6. VS7.1 allows you to, however...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi,
I wonder if anyone have an idea how to make an directx overlay (or however its called). I mean something like xfire or TS has, when you run a game, and some1 sends you a message there is a small box drawn in the game from xfire. You know how to do It ? any help appreciated
|
|
|
|
|
Please check the following snippet of code where I have used
AddStore() to add a pst file to a profile. This works in some pcs
while in others it fails with "Outlook faled to add the personal store
to this session". Any ideas?
<br />
_Application olApplication;<br />
_NameSpace olNameSpace;<br />
COleException e;<br />
if(!olApplication.CreateDispatch("Outlook.Application", &e)) {<br />
CString str;<br />
str.Format("CreateDispatch() failed w/error 0x%08lx", e.m_sc);<br />
AfxMessageBox(str, MB_SETFOREGROUND);<br />
}<br />
else {<br />
<br />
olNameSpace = olApplication.GetNamespace("MAPI");<br />
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);<br />
olNameSpace2.Logon(covOptional2, covOptional2, covOptional2,<br />
covOptional2);<br />
}<br />
olNameSpace.AddStore(COleVariant(strDestinyPstPath));<br />
Thanks.
Best Regards,
kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?"
|
|
|
|
|
Before delving into hex numbers and memory addresses, does anyone have any advice on using "#define new DEBUG_NEW" as an option in DEBUG in VS2003 Standard Edition?
I have the following switches on (/MDd, _DEBUG, /ZI) but as far as I can tell the compiler is not loading the debug library cos it comes up with the following "error C2665: 'operator new' : none of the 5 overloads can convert parameter 1 from type 'const char [71]'" in the "xmemory" file.
I assume this is because the compiler has translated the macro as a string and not a bunch of debug expressions. Is that the correct diagnosis?
What should I change in the project settings to get this to work?
TIA
PS Obviously, the point to all of this is hunting down memory allocations using "new".
|
|
|
|
|
Hello,
I think that you use the DEBUG_NEW macro without including the proper headers. You arn't using MFC are you? See here[^] for more details on DEBUG_NEW
The above method is very basic in detecting memory leaks. If you need good support for the leaks, I can suggest Visual Leak Detector[^] as an excellent open source tool. It worked for me in some of my projects.
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hi, is there anyway in C++ that I could get the size of a simple type array?
I'm trying to pass an array to a function without passing the size of the array..
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
not in general.
if you know the arrays are always allocated with malloc, calloc or realloc, you can use _msize to get the allocated size, then divide by the type size. but that's a giant hack and is very likely to lead to disaster (ex. if someone passes an array that was created on the stack or via new)
it's best to just pass the array size, or use a dynamic container like std::vector.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris Losinger wrote:
but that's a giant hack and is an very likely to lead to disaster (ex. if someone passes an array that was created on the stack or via new)
For that reason, I never could get the infamous countof to work!
#define countof(X) (sizeof(X) / sizeof((X)[0]))
Good to know why it doesn't work..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
That macro only works if the compiler can see X as an array:
#define COUNT_OF(X) (sizeof(X) / sizeof((X)[0]))
void DisplayNumbers(int[6] numbers);
void DisplayNumbers2(int* pNumbers);
void DisplayNumbers3(int* pNumbers, int nSize);
void main()
{
int numbers[] = {1, 2, 3, 5, 8, 13};
int nSize = COUNT_OF(numbers);
DisplayNumbers(numbers);
DisplayNumbers2(numbers);
DisplayNumbers3(numbers, nSize);
}
void DisplayNumbers(int[6] numbers)
{
printf("DisplayNumbers shows:\n ");
int nSize = COUNT_OF(numbers);
for (int i = 0; i < nSize; ++i)
printf("%d ", numbers[i]);
printf("\n");
}
void DisplayNumbers2(int* pNumbers)
{
printf("DisplayNumbers2 shows:\n ");
int nSize = COUNT_OF(pNumbers);
for (int i = 0; i < nSize; ++i)
printf("%d ", numbers[i]);
printf("\n");
}
void DisplayNumbers3(int* pNumbers, int nSize)
{
printf("DisplayNumbers3 shows:\n ");
for (int i = 0; i < nSize; ++i)
printf("%d ", numbers[i]);
printf("\n");
}
The output for this program would be:
DisplayNumbers shows:
1 2 3 5 8 13
DisplayNumbers2 shows:
1
DisplayNumbers3 shows:
1 2 3 5 8 13
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Chris Losinger wrote:
it's best to just pass the array size, or use a dynamic container like std::vector.
True. Another alternative, which is used sometimes for arrays of pointers, are NULL terminated arrays.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|