|
Hi all,
Please let me know how to give the publisher name to my sample MFC application.
Currently it is displaying "Unknown" when i try to start it.
I am using Visual Studio 2008.
To see the publisher name -> Run an application as administrator in windows 7 machine and check the UAC dialog.
-Cvaji
|
|
|
|
|
|
Nice of you to post your finding. Not many people do that. Good Luck with your new Publisher Name
|
|
|
|
|
this[^] should be your first step.
|
|
|
|
|
Hey guys,
I have a project which connects the TVs(with socket connection) to a computer and saves the log files. I achieve the connection by multithreading but I want to see whether the connection is established or not in the main dialog page that i built in VC++ MFC. Here are my codes:
void CDilaraDlg::OnBnClickedConnect()
{
int Selected = 0;
for(int i=0; i< m_ctlServerList.GetCount();i++)
{
if(m_ctlServerList.GetCheck(i) == 1 )
{
Selected++;
}
}
if(Selected == 0)
AfxMessageBox(L"No Server is Selected!");
CString *diziPtr= new CString[Selected];
char str[2];
CString svar;
for(int i=0; i< m_ctlServerList.GetCount();i++)
{
if(m_ctlServerList.GetCheck(i) == 1 )
{
_itoa_s(i,str,10);
svar = str;
*diziPtr = lines[i]+_T(":")+svar+_T("-")+m_savepath;
++diziPtr;
}
}
m_fails.ResetContent();
m_success.ResetContent();
CString abc;
for(int i=0;i<Selected;i++)
{
--diziPtr;
Client_Thread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ClientThread,(void *)diziPtr,0,&Client_ThreadID);
}
m_fails and m_success stand for the control variables of two list boxes that i want to write down the succeed and failed connections.
For the multithreading :
DWORD WINAPI ClientThread(void * num)
{
signal( SIGINT, &signal_handler );
signal( SIGTERM,&signal_handler );
signal( SIGABRT,&signal_handler );
CString ipport= *(CString * ) num;
CString ipAddress,savepath;
CString ports,socknums;
int port,socknum;
AfxExtractSubString(ipAddress, ipport, 0, ':');
AfxExtractSubString(ports, ipport, 1, ':');
port = _wtoi(ports);
AfxExtractSubString(socknums, ipport, 2, ':');
AfxExtractSubString(savepath, ipport, 1, '-');
socknum = _wtoi(socknums);
CStringA ip(ipAddress);
Socket sockClient(socknum);
sockClient.timefile(ipAddress,ports,savepath);
if(sockClient.ConnectToServer(ip, port,socknum)==0)
return -1;
sockClient.RecvData(ipAddress,ports,socknum,savepath);
return 0;
}
in the ConnectToServer function of the Socket, it returns 0 if the connection is not achieved and 1 otherwise.
int Socket::ConnectToServer( const char *ipAddress, int port,int i)
{
myAddress.sin_family = AF_INET;
myAddress.sin_addr.s_addr = inet_addr( ipAddress );
myAddress.sin_port = htons( port );
if (connect( mySocket[i], (SOCKADDR*) &myAddress, sizeof( myAddress )) ==SOCKET_ERROR )
{
CString msg = _T("ClientSocket: Failed to connect: Error Value: ");
CString error;
int a = WSAGetLastError();
error.Format(_T("%d"),a);
msg+=error;
AfxMessageBox(msg);
system("pause");
return 0;
}
return 1;
}
How to get 0 or 1 return values in my dialog.cpp to do the listbox operations? or any other suggestions??
Thanks
|
|
|
|
|
dilara semerci wrote: How to get 0 or 1 return values in my dialog.cpp to do the listbox operations? or any other suggestions??
I could think of two alternatives. First, use PostMessage() to notify the user interface that something has happened (e.g. socket connected, status changes), therefore you need to give your worker thread the window handle of your dialog. Second, use non-blocking sockets and your can handle everything in a single-thread context with event handlers (e.g. OnConnect , OnReceive ).
The first alternative can be added to your existing application and should be running quickly. The second requires code refactoring, but probably is easier to extend and maintain in the long run... so it really depends on your application requirements/features what's better.
Hope this gives you some ideas.
/M
|
|
|
|
|
I checked PostMessage() but i could not find a way to use it in application.. all the thread kind of examples are done by non-blocking asyn.sockets. can you help me to understand and use PostMessage() method? what else do i need to add my code and where of course?
|
|
|
|
|
Here is a brief guide:
- Give window handle to the worker thread (typically from a dialog or the main view)
- Send a custom message with PostMessage (WM_APP + something) when a socket signals a certain status
- Add a handler for your custom message to the dialog, update the listbox with the status
|
|
|
|
|
Hi all,
I am trying to read a port using CreateFile() and ReadFile() Function using overlapped parameter, but my problem is when i debug the program number of bytes read is coming correct and when i run my program bytes read is coming less... I am not getting why is this happening...
Can anybody help me in this...
Thanks in advance
|
|
|
|
|
Show some code.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
that is insufficient information to offer you any help.
explain what you are doing, show the relevant code, and give us precise symptoms: how many bytes when good, how many when bad, and how repeatable is that?
|
|
|
|
|
|
What do you mean by "user defined function" ? Your question is not clear at all.
Why can't you just call the function like this: abcFunc(); ?
Is is a global function ? If yes, why are you calling it on a class instance ?
|
|
|
|
|
thanx alot....it worked for me. Im calling it uer-defined because I wrote it myself, not the wizard generated it. But if I am wrong, plz guide me.
|
|
|
|
|
It seems that you have lacks in knowledge about programming basics (in general) and C/C++ basics... I think the best for you is to buy a good book
|
|
|
|
|
Don't know where you are coming from and where you are going ...
This is very basic beginner C/C++
Go back to your class notes (books) and re-read all of them, especially the first few chapters.
because I'm an easy going guy and did not got a lot of sleep because of overly chatty neighbors (they were awake 'till 5am) I'm going to help you a little bit...
1. just call the function.
VOID abcFunc()
{
}
void ABC() {
abcFunc();
}
2.
who defines ABC() ? who calls that function ?
what is dwInstance ?
is the method abcFun() defined in the CExampleDlg class ?
void ABC() {
CExampleDlg *pointer = (CExampleDlg*) dwInstance;
pointer->abcFunc();
}
Good luck ... keep going... and don't forget to drink a lot of water, it's good for you.
M.
Watched code never compiles.
|
|
|
|
|
Hi everybody,
I am using shock wave flash control on a dialog. I able to play the movie file(.swf file) But I want to make the background as transparent while playing the swf file.There is an article named "transparent flash control in plain C++" that solved this problem, but the usage of cpu is too high.Does someone have a solution?
Thanks!
|
|
|
|
|
I use CodeBlocks 10.05, I want use C dll in .NET.
I write following code in CodeBlocks 10.05 compiler, but get error when I build it.
#include <stdio.h>
extern "C" __declspec(dllexport) int GetLuckyNumber()
{
return 13;
}
ERROR MESSAGE
error: expected identifier or '(' before string constant
|
|
|
|
|
Hi,
I've never seen extern "C" without curly brackets, so try
extern "C" { ... unmangled C code here ...}<br />
|
|
|
|
|
extern "C" will work without curly brackets.
Curly brackets are required if you need to include multiple lines in the scope of extern "C" .
|
|
|
|
|
If we're being picky here, the actual condition is not "multiple lines" but "more than a single declaration". Refer section 7.4 of the standard. For example,
extern "C"
double
sqrt(
double)
;
is OK, but
extern "C" double sqrt(double); double exp(double);
and
extern "C" int square(int x) {return x*x;}
are not.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
What compiler do you use in your IDE environment?
I think __declspec(dllexport) is only for MS compiler, not for gcc.
|
|
|
|
|
|
If you're using gcc file.c from the command line, then that could be the problem - gcc is the C compiler and extern "C" is C++ code.
Use g++ file.c , or make sure the file extension is .cpp or .c++ for gcc to compile it as C++.
|
|
|
|
|
This is just the solution for original question, I think.
|
|
|
|