|
Hi,
I am in very New to VC, and I have written a code which will connect to another machine and return either a -1 or non negative value.
I am getting a "-1" for bind function. Please can some one help me
out with it..
==============================================================
#include <stdio.h>
#include <winsock.h>
#include <windows.h>
#include <iostream.h>
WSADATA wsData;
SOCKADDR_IN saServer;
SOCKET s;
void main()
{
WORD wVersionRequested = MAKEWORD(1,1);
int nRet,sd,d;
//
// Initialize WinSock
//
nRet = WSAStartup(wVersionRequested, &wsData);
printf("WSASTARTUP nret = %d\n",nRet);
sd = socket(AF_INET, SOCK_STREAM, 0);
printf("SOCKET = %ld\n",s);
saServer.sin_family=AF_INET;
saServer.sin_addr.s_addr = inet_addr("192.168.0.4");
saServer.sin_port=htons(80);
d = bind(s,(struct sockaddr*)&saServer,sizeof(saServer));
printf("BIND = %ld\n",d);
getchar();
}
=============================================================
|
|
|
|
|
try this:
memset((char *) &saServer, 0, sizeof(saServer));
saServer.sin_family=AF_INET;
saServer.sin_addr.s_addr = inet_addr("192.168.0.4");
saServer.sin_port=htons(80);
|
|
|
|
|
Hi guys.
I have a CListCtrl control in my application. I would to let one of its items be selected when the user click some buttons.
How can I do?
CListCtrl::SetHotItem doesn't work.
Hi guys. I'm a very fat man. Do you like fat men?
|
|
|
|
|
Use SetItem. mask = LVIF_STATE, state = LVIS_SELECTED;
|
|
|
|
|
I Developed a MFC dialog box,i want insert a flash file in the DialogBox, how can i do this ?
Any help...
Thank you.
|
|
|
|
|
Its simple.
I have done that for my screensaver.
Add Shockwave ActiveX control to your dialog by
Project->Add Components.
THen there in registered activeX components and then ShockWave ActiveX or watever u want.
Then put it in ur dialog and add a member variable to your activeX control.
Then use this code in ur app
<br />
m_flash.SetMovie(strFile);<br />
m_flash.Play();<br />
-----------------------------------------------------------
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
I write header file "ooo.h" and want to write this below text in ooo.h
#define X "123"
This below is some part of my code
************************************************
FILE *outp;
CString output_filename;
Output_filename = "ooo.h";
outp = fopen(output_filename, "w");
fprintf(outp, "#define X "123" ");
fprintf(outp, "\n");
if (output_filename)
{
fclose(outp);
}
************************************************
When I compile program there are 2 error messages happen cause by this line
fprintf(outp, "#define X "123" ");
I change that line to
fprintf(outp, "#define X 123");
So I can compile program and it write
#define X 123
but I want
#define X "123"
If you know how to solve my problem? Please tell me.
Thank you.
|
|
|
|
|
ooosawaddee3 wrote:
fprintf(outp, "#define X "123" ");
you need to escape some of these quotes:
fprintf( outp, "#define X \"123\" \n" );
try that...
Just trying to keep the forces of entropy at bay
|
|
|
|
|
use
\" in place of "
A Programmer Never Dies..***
|
|
|
|
|
I create a process(a console application), and after some operations, i need to terminate it. Now I use TerminateProcess() function, and it does work. But i'd rather like the process exit normally. So i need to send some keyboard messages('Esc' and 'n') first, then terminate it. How?
Thanks!
|
|
|
|
|
AttachThreadInput + SendInput
|
|
|
|
|
I have tried AttatchThreadInput() and keybd_event() instead, but they can't work properly.
keybd_event() does simulate a keyboard message, but only my thread received it, and the child process doesn't.
Can you give me some further advice?
|
|
|
|
|
Please explain exactly what you have done, and what you want to do. With this information I could answer "Scream and shout" and it would be an answer equally correct and incorrect.
|
|
|
|
|
Ok code first;
dll:
__declspec(dllexport) void AlstgPlug( void );
in exe:
typedef void (CALLBACK* MYFUNC)(void);
HINSTANCE hDLL = AfxLoadLibrary("FOUS21.dll");
if (hDLL)
{
FARPROC pnProc = GetProcAddress (hDLL, "AlstgPlug");
MYFUNC pnMyfunc = (MYFUNC)pnProc;
(pnMyfunc)();
FreeLibrary(hDLL);
}
It fails at the function call pnMyfunc(); It exits completely. If you need more info just ask. I am new to this so please don't assune I remembered some critical, or small step. Thanks in advance
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
Darroll wrote:
(pnMyfunc)();
try:
(*pnMyfunc)();
Just trying to keep the forces of entropy at bay
|
|
|
|
|
RedZenBird wrote:
try:
(*pnMyfunc)();
It does not matter. You might write: pnMyFunc(). That's not the point. Remove CALLBACK specification since your function declared as __cdecl, whereas CALLBACK use __stdcall specification
|
|
|
|
|
just do by reference
A Programmer Never Dies...
|
|
|
|
|
I have a header-style list control with two columns. I'm wanting to put an image in the 2nd column (have already successfully put an image with text in the first column). Here's how I'm doing it:
PlayerListCtrl.SetItem(nItem,1,LVIF_IMAGE,0,2,0,0,i);
What am I doing wrong?
Thanks!
|
|
|
|
|
There is no standard way to assign image to any other column except first.
You must draw it manually. Use for this purpose a NM_CUSTOMDRAW notify event. CDDS_SUBITEM indicate a current drawing subitem column. For additional info see MSDN
|
|
|
|
|
|
Thanks, that's EXACTLY what I needed!
|
|
|
|
|
The Free Ram will droped down,I want to frees up ram by myself,but I don't
know how to do it.Please give me some advice,a part of source code is perfect.
|
|
|
|
|
ummmmm are you saying u have a memory leak in your code somewhere? if so u just gots to go look hard and find it
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" biz stuff about me
|
|
|
|
|
thank you
yes,i meet the problem,but now i want to make little program just like FreeRam, can u give me some advice
|
|
|
|
|
Hi Guys,
I asked this before and didn't get any favourable answers, and I'm still struggling with this:
Issue:
When I read a BINARY file, and writing to back, I get an ASSERT
ASSERT(lpBuf != NULL);
because my binary files contain spaces and null. And when I write it back, the program treats the buffer as NULL so it throws the ASSERT.
********However, it works for text files.*******
Is there anything I'm missing? After couple of loops of the binary read operation, buf is.... buf=""; but the bytes read still the right amount. Any help will be really appreciated.
Do these kind of things happen to everyone or just me?
CClient::Read(BYTE *buf, int iSize){
CFile pFile (sFilename, CFile::modeRead|typeBinary);
while(true){
iReadSize = pFile.Read(pBuf, 4045);
if(iReadSize == 0)
break;
}
}
//this is in an async. callback fn..the event will call it up
CServer::Write(BYTE *buf, int iSize)
{
CFile pFile (sFilename, CFile::modeWrite|typeBinary);
pFile.Write(buf, iSize);
}
My ass is on fire and my brain's on smoke.
JJ
|
|
|
|