|
To put it simply, the loop will end when the expression "(*d++=*s++)" becomes zero. It will be zero when *d++ becomes zero. The *d++ will become zero when a zero is written to its address (which means that a zero will be copied from the *s++ source).
This code copies data from the address pointed to by "s" into the address pointed to by "d". After using both addresses "s" an "d" they will be incremented, thus pointing to the next element to copy.
The loop will stop after copying a null byte. So, most probably, it is an algorithm to copy null-terminated strings.
|
|
|
|
|
how i can send text from my program to testbox in external program
|
|
|
|
|
Have you looked at SetWindowText() ?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Do you mean like keystrokes ( keyboard emulator ) ?
Do you want to send any data ( text or whatever kind of data ) to another application / program that running ?
AFAIK, there is a library on .NET to do it, called SendKeys.
But if you do not use any .NET then you may have to search on WINAPI documentation.
|
|
|
|
|
Why don't you store your text into an ASCII-file and read this file in the external program?
Good luck, Gerard
|
|
|
|
|
He can send his text direct to a program
|
|
|
|
|
|
yes it solved but some program didnt recive the text so i ahve its handle
|
|
|
|
|
As a security measure, we're trying to stop an application of our own creation having access to explicitly linked DLLs unless those DLLs are "licensed" for the particular installation of the application on a single PC. Each DLL typically exports the same basic functionality.
Thought occurs that a sneaky user could, knowing the name of a licensed DLL, rename another DLL to that name and get around the licence issue.
From looking at the binary of a DLL, the compiled name of the DLL is embedded therein, just before the list of exported functions. Is there a method for accessing this name programmatically, to check that it matches the actual physical filename (otherwise, the application will refuse to load the DLL)?
|
|
|
|
|
I have a problem related to a window that in some cases owns a context/popup menu.
Here is the code for the creation and tracking of the popup menu:
LRESULT
MyWindowClass::OnCreateAndTrackPopupMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
HMENU aMenu = ::LoadMenu(_Module.GetResourceInstance(),(LPCTSTR)IDR_CONTEXT_MENU);
if(aMenu != NULL)
{
HMENU hSubMenu = ::GetSubMenu(aMenu,0);
if(hSubMenu != NULL)
{
SetForegroundWindow(m_hWnd);
TrackPopupMenuEx(hSubMenu,TPM_LEFTALIGN|TPM_TOPALIGN,pt.x,pt.y,m_hWnd,NULL);
::PostMessage(m_hWnd, WM_NULL, 0, 0);
}
::DestroyMenu(aMenu);
}
return 0;
}
My application response to a window message that should deal with the destruction of the window above:
LRESULT
MyMainClass::OnDestroyWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
::PostMessage(MyWindowClass->m_hWnd,WM_CANCELMODE,0,0);
MyWindowClass->DestroyWindow();
delete MyWindowClass;
MyWindowClass= NULL;
return 0;
}
The problem: If the popup menu is present when the destruction (DestroyWindow()) takes place, the application will crash ("ERROR - Object deleted before window was destroyed"), because the popup menu still is active (still waiting for TrackPopupMenuEx() to return because WM_CANCELMODE never reach the window before it is destroyed).
So the question is, how can I make sure that the OnCreateAndTrackPopupMenu-function return before DestroyWindow() is executed?
john
|
|
|
|
|
you can do something like :
You call DestroyWindow ( to delete the Window object ), this will eventually call PostNcDestroy, in which you will do a delete this , to delete the C++ object,and before that, send a message ( SendMessage ) to the caller of the window to set its pointer to NULL.
For example :
void MyAutoDeleteDialog::PostNcDestroy()
{
BaseDialog::PostNcDestroy();
AfxGetMainWnd()->SendMessage( WM_AUTO_DELETE_DIALOG_CLOSED, 0, 0 );
delete this;
}
|
|
|
|
|
Thanx for the quick response. I understand your solution and what it does, but it doesn't seem like it solves my problem. I need to cancel the dialog before the object is deleted by using WM_CANCELMODE. How does this fit into the solution?
john
|
|
|
|
|
|
This doesn't do it for some reason. Maybe WM_CANCELMODE IS received synchronically, but TrackPopupMenu() never returns anyhow, before it is too late and the object is deleted - crash .
john
|
|
|
|
|
Hi Everyone, i am still having troule with this over a wan... can anyone shed any light on it for me ?? i am getting kinda desperate now !!
CFtpConnection Thread......
Thanks in advance
Lee
|
|
|
|
|
try to find sample programs in VC disks (MSDN).
FTP is very easy.
|
|
|
|
|
i have done... and the way i have written it works on the local network, but i have a router set up with 3-5 pcs on it and am using port forwarding, if i leave the ftp port at 21 it works fine, if i change the port to anything else i can connect and create folders etc, but cannot do file searches or transfer files... i need to have it on different port as i have upto 5 pcs to forward to...
please help....
|
|
|
|
|
Open your MSDN -> choose Index tab -> Type: FTP Sessions -> Enter
Sincerely
Thangnvhl
|
|
|
|
|
my problem isnt how to use msdn, as i have been programming for 6+ years.. and have used it a fair amount in that time... i have downloaded some sameple programs from this site and they all have the same problem....
|
|
|
|
|
are you forwarding your data port as well?
|
|
|
|
|
i dont know what port the data port is... can i set this up ?? if i use port 21 it works ok...
|
|
|
|
|
Here[^] is a decent explanation.
|
|
|
|
|
Hi,
In a current project I need a class that monitors some maintenance data and regularly writes them to a log file. As this class is used in different modules in different ways, the functions should be encapsulated as best as possible and the usual way of using this class should be by giving a filename to the constructor to configure the instance and then calling Collect() to immediately collect and log the data or calling EnableTimer(time_span) to regularly log the data to the log file every time_span milliseconds.
The problem I can't solve is the timer. My first approach was
<br />
<br />
BOOL CMaintMonitor::EnableTimer(UINT interval)<br />
{<br />
if(bl_TimerEnabled) StopTimer();<br />
bl_TimerEnabled = TRUE;<br />
ui_TimerInterval = interval;<br />
TimerID = SetTimer(NULL, 0, interval, TimerFunction);<br />
if(!TimerID)<br />
{<br />
bl_TimerEnabled = FALSE;<br />
ui_TimerInterval = 0;<br />
return FALSE;<br />
}<br />
return TRUE;<br />
}<br />
<br />
...<br />
<br />
BOOL CMaintMonitor::StopTimer()<br />
{<br />
if(bl_TimerEnabled)<br />
{<br />
bl_TimerEnabled = FALSE;<br />
ui_TimerInterval = 0;<br />
KillTimer(TimerID);<br />
}<br />
return TRUE;<br />
}<br />
TimerFunction was thought as a private method of CMaintMonitor that calls Collect(). Visual C++ didn't like this approach, telling me that it couldn't convert parameter 4 of SetTimer from void(...) to void(__stdcall *)(...). Reading the help pages again I saw that this function is meant to send a WM_TIMER message to a window whose message processing function should call the provided function instead of standard functions, so it still needs a WM_TIMER message processing even if the window handle provided is NULL .
The problem now is that I can't call a global function (I think this is what the compiler wants to say with the (__stdcall *) part of the error message) as Collect is a member function of an instance of CMaintMonitor using instance member data to do its work. So even if I found a way to use a global function for that timer event, I still need a way to give a pointer to my CMaintMonitor instance to that function for the call to Collect(), but I don't see a way to do so.
Can anyone help me solving the problem with that timer? This class should come without a user-Interface, so there is no window I can abuse to handle the timer event, and I can't even use the window of a caller as there are a lot of modules which come without UI either but still need to to use my monitor class. I'm new to programming under Windows, so I don't know if there might be an easy workaround for this problem I just don't know.
Thanks in advance
Martin Dietz
|
|
|
|
|
|
This looks interesting, but I can't find it in my helppages and my compiler doesn't find it neither although I included windows.h (as said in the MSDN article), is it available in Visual C++ 6.0 (sorry I forgot to mention that I'm pinned to that compiler)?
Greetings
Martin
|
|
|
|