|
Wrong forum. Ask in VC++[^] forum instead.
|
|
|
|
|
Bulky Fellow wrote: What rubbish? Does that code look anything like VC++ to you? I guess
one look at the
first include must have fooled you. Did you even bother reading the
code?
If you can't solve something (and also give wrong directions like a
jackass), just
shut up and sit still instead of blabbering.
I'm not sure, why you have deleted this post ? If you think, this is right forum for this question, why you have posted it in VC++ fourm again.
You have not read sticky post by Chris[^] , before posting this question.
I wanted you to get good answers, thats why was directing you to VC++ forums.
|
|
|
|
|
Hi,
I have a Client-Server Application. I am trying to get the IP address of the machine on which the client is running on at the Server Side. I want to store the IP address at the Server side and use it for future processing.
How to get the IP address of the client machine.
I am using VC++ 6.0
Thanks n regards
-- modified at 4:49 Monday 26th February, 2007
|
|
|
|
|
Use gethostbyname name.
MSDN has this example given,
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
void main()
{
WSADATA wsaData;
char szHostname[100];
HOSTENT *pHostEnt;
int nAdapter = 0;
struct sockaddr_in sAddr;
if (WSAStartup(0x0101, &wsaData))
{
printf("WSAStartup failed %s\n", WSAGetLastError());
return;
}
gethostname( szHostname, sizeof( szHostname ));
pHostEnt = gethostbyname( szHostname );
while ( pHostEnt->h_addr_list[nAdapter] )
{
memcpy ( &sAddr.sin_addr.s_addr, pHostEnt->h_addr_list[nAdapter],
pHostEnt->h_length);
printf("Name: %s\nAddress: %s\n", pHostEnt->h_name,
inet_ntoa(sAddr.sin_addr));
nAdapter++;
}
WSACleanup();
return;
}
Vichitram wrote: I am using VC++ 6.0
You should have asked this question in VC++ forum.
|
|
|
|
|
Vichitram wrote:
I am using VC++ 6.0
Then you're plainly not using C++/CLI
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I am trying to use a FolderBrowserDialog to get a folder and set the path to a text field on my form. The first problem I came up against was a blank folder listing which I had to rectify by making the FolderBrowserDialog spawn as a STA ApartmentState. Now the problem is that I can't get the SelectedPath back onto my calling form.
Here is my code for my Click event to open the FolderBrowserDialog and the subsequent settings:
private: System::Void OnClicked_ID_GETPHOTO_DIR(System::Object^ sender, System::EventArgs^ e) {<br />
Thread^ newThread = gcnew Thread ( gcnew ThreadStart( this, &Picture_Importer::Form_Start::Get_Directory ) );<br />
newThread->SetApartmentState(ApartmentState::STA);<br />
newThread->Start();<br />
}<br />
<br />
private: void Get_Directory() {<br />
this->folderBrowserDialog1->SelectedPath = "c:\\";<br />
<br />
this->folderBrowserDialog1->Description = "Select the directory that you want to use as the default.";<br />
<br />
this->folderBrowserDialog1->ShowNewFolderButton = false;<br />
<br />
System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();<br />
if ( result == ::DialogResult::OK )<br />
{<br />
folderName = folderBrowserDialog1->SelectedPath;<br />
this->ID_PHOTO_DIR->Text = folderName;<br />
}<br />
<br />
}
The problem is when I run the code and it gets to this->ID_PHOTO_DIR->Text = folderName; it chokes with
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll<br />
<br />
Additional information: Cross-thread operation not valid: Control 'ID_PHOTO_DIR' access from a thread other than the thread it was created on.
I am new to this programming language, so please be gentle with me. I appreciate what the message is saying I just don't get how to fix it.
|
|
|
|
|
|
Hi!!
I've been reading about multithreading in this page, but i can't compile the example written here.
I'm using Borland C++ 5.5.1 for Win32 and my config files are
bcc32
-I"C:\Borland\BCC55\Include"<br />
-L"C:\Borland\BCC55\Lib;C:\Borland\BCC55\Lib\PSDK<br />
-P<br />
-v-<br />
-w<br />
-D_WIN32_WINNT=0x0400
Ilink32
-v-<br />
-x<br />
-L"C:\Borland\BCC55\Lib;C:\Borland\BCC55\Lib\PSDK;C:\WINDOWS\system32"
And the error that the compiler gives me is
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland<br />
thread.c:<br />
Error E2268 thread.c 30: Call to undefined function '_beginthread' in function main()<br />
Error E2268 thread.c 46: Call to undefined function '_endthread' in function ThreadProc(void *)<br />
*** 2 errors in Compile ***<br />
can someone help me??
what am i doing wrong??
i'am a beginner in multithreading...
greetings!!
|
|
|
|
|
venetus wrote: I'm using Borland C++ 5.5.1
Then you can't possibly be using C++/CLI. You could try the visual C++ forum, but a Borland forum would be more sensible, if there is one.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
As I can see there is no problem with multithreading, but with the functions You've used. Compiler doesn't know these functions. Have you included <process.h> ??
|
|
|
|
|
i just copy and pasted the example...
what do you think i have to include???
|
|
|
|
|
i've just compile the example with Dev and it worked. But i don't know why it doesn't work with Borland compiler...
Any hint?
|
|
|
|
|
Which example? There are 3 examples
|
|
|
|
|
this one "Download demo project in C - 3 Kb"
bye
|
|
|
|
|
I've tried it with Builder 6.0 and it's worked fine.
Probably you haven't checked the Multi Threaded check box in File\new\other...\console wizard dialog. Make sure it's checked.
|
|
|
|
|
this is STILL the wrong forum to be talking about this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i would add a dll in my project but i don't know how i can introduce him, iam viewing a reference but i can't add him, i work with Visual Studio 2005 please help me.
Thank you very mutch.
|
|
|
|
|
What is the DLL written in ? You can add references to COM dlls and .NET dlls ( assuming your question is in the right forum and you are using C++/CLI ), I don't think you can import plain dlls, you can p/invoke them ( again, if you really are using C++/CLI ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hey guys,
few days ago somebody ask me that where it is mandatory to define copy constructor i.e without making an explicit call we can not solve our problem..
so i need to know what would be that condition as i am also searching for the same from 2-3 days ...
if anybody can help me in getting the answer i'll greateful to him/her..
Thank you
Regards,
Pankaj Sachdeva
|
|
|
|
|
pan_angel wrote: where it is mandatory to define copy construc
It is not mandateroy to define copy c'to. But, it is required to define in cases where, one of member variable is pointer and uses dynamic memory allocation.
class A
{
char *m_pName;
int m_nid;
public:
A(char *pName,int nId)
{
m_pName = new char [strlen(pName)+1] ;
strcpy(m_pName,pName);
nid = nId;
}
~A()
{
delete []m_pName;
m_pName = NULL;
}
};
int main()
{
A aObj("Prasad",1);
A aObj1 = aObj;
}
So should modify your defintion to,
class A
{
char *m_pName;
int m_nid;
public:
A(char *pName,int nId)
{
m_pName = new char [strlen(pName)+1] ;
strcpy(m_pName,pName);
m_nid = nId;
}
A(A& aObj)
{
int nMemoryToAlloacate = strlen(aObj's char pointer);
m_pName = new char [nMemoryToAlloacate + 1] ;
strcpy(m_pName,aObj's char pointer);
m_nid = aObj's m_nid ;
}
~A()
{
delete []m_pName;
m_pName = NULL;
}
};
|
|
|
|
|
Objects can be passed to functions by value or by reference. If they are passed by value, a copy of each object is passed to the function. The default method for creating the copy is memberwise copy (shallow copy). This can be modified by supplying a user-defined copy constructor.
|
|
|
|
|
This is not a C++/CLI question, it should have been asked in the Visual C++ forum. You need a copy constructor when you have a pointer, or whenever you have an object which would automatically only provide a shallow copy, and a deep copy is required.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
I'm trying to create a Observer functionallity between a unmanaged C++ and a managed C++ Class. My managed C++-Class will be used as a Wrapper Class to connect the unmanaged Code to a C# Class. Now I have a Interface Class in my unmaganed Code and wanted to heritate my Wrapper-Class from it. But there ist the Problem. Its not possible to heritate a managed class from a unmanaged class.
The aim is, that my unmanaged Code has to call a method in managed Code.
Can someone help me to find an other solution?
Thanks
|
|
|
|
|
I did a similar thing with containment. The manaed object contains the unmanaged object and exposes all the same methods but with dot net data types. Each method converts data types of params if nessasary and cals the method on the unmanaged object. See this wonderfull article[^] for a smart pointer template you can use to manage the lifetime of unamanged objects
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|