|
I've got a friend who I work with who asked me to program an application for his wife who is a teacher. The problem? She teaches a computer course and when she is talking or teaching, the kids are ignoring her and playing on the computer.
She'd like to have an application on her desktop computer that remotely locks/unlocks the keyboard and mouse of all of her students' computers. Of course when the students' computers are locked, a message should be displayed as they type (pound?) on the keyboard or move the mouse.
I figured a couple of hooks (system wide) for mouse and keyboard should do it. I'm new to the subject and have read a couple of the articles here on CodeProject but have some questions. One article said that you shouldn't use MFC and/or C runtime library calls. No problem but I need to communicate to the teacher's computer using Winsock so my question is since, I believe, that Winsock is part of the platform SDK and/or part of the standard Win32 API, can I use Winsock in the global dll implementation? Or, should it be a separate executable that communicates with the DLL via windows messages and relays the commands to the server app (teacher's computer) via Winsock?
Anyone have any suggestions on how I should implement this? I figure the teacher runs an executable on her machine that sends/receives command to the students' (client) computers using Winsock. The students' computers should all run the DLL (should this be a service?) or should I also create an executable for the clients that install the DLL and autoruns as a service?
OT. Why hasn't anyone already built this application and is it worth selling?
|
|
|
|
|
I have a string that might contain one or more occurences of 'search' text and I want to replace all occurrences with some 'replace' text.
However, it can not be the usual dumb replacement, because I can not afford to have the text Tag100 replaced with TAG200 if the search text is 'TAG1' and the replace text is 'TAG2'.
Anyone know existing locations of some 'smart' text replacement code in C or C++?
|
|
|
|
|
I am not sure if the regular expression search in VC++ can do it, but I am sure that Regex++ can. Regex++ is part of the boost library and is free for downloading.
I hope that helps!
Good Luck!
INTP
|
|
|
|
|
Strange! I have a server and a client. Using straight winsock2 API and event notifications. Dual processor machine!!!
Problems/obesvations:
1) If client and server are both running on the dual processor (same computer) and client allowed to use both processors, often but not always client does NOT get notification about incomming data.
2) If client and server are both running on the dual processor (same computer) and client is limited to either processor, client gets all the notifications fine.
3) If client is running on the dual processor and allowed to use either processor, and Server is running on a different machine, client gets all the notifications fine.
4) If Server is running on the Dual processor and can use either processor, and client is running on a different machine, often but not always client does NOT get notification about incomming data.
5) If Server is running on the Dual processor and is restricted to a single processor, and client
is running on a different machine, often but not always client does NOT get notification about incomming data.
6) If client and Server are both run on same dual proc machine, and server restricted to one processor but client is allowed to use both, often but not always client does NOT get notification about incomming data.
Any ideas why?
Help!
|
|
|
|
|
I've run across this myself. Are you spawning the socket in its own thread? It seems that sockets aren't inherently thread-safe, so the easiest way I found to work around this is to keep the socket in the UI thread (for better or worse).
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Wow! You lost me there. Should I or should I not spawn it in it's own thread? Also how does UI trhead solve that? Excuse my uneducated ignorance.
Do you mean you post messages to that thread with things to do?
|
|
|
|
|
hai,
I'm working on VC++ win32...In my program i'm reading some ascii characters in char[] from say a file. I want to convert the ascii char to binary value...is there any easy way to do the conversion??pls help...
Thanks a lot.
|
|
|
|
|
Was this of no help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
No..I want to convert to binary..
|
|
|
|
|
It's imply another base. Use itoa() to convert from one base to another.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The value of a single ascii char is just 1 byte (supports 256 different chars (including whitespaces linefeeds etc...) so what more is there to convert?
Greetz,
Davy
|
|
|
|
|
Actually what I want to do exactly is..I'm reading a char from a file into a byte array. eg. suppose I'm reading a "A" from the file I have to display the binary equivalent '01000001'. How should I do this programatically.
Thanks a lot.
|
|
|
|
|
Do you mean you want a text string containing the ones and zeroes of the binary value?
If so this may help
string ConvertToBinary(TCHAR ch)
{
string out;
int size = sizeof(TCHAR) * 8;
for (int i = size - 1; i >= 0; --i)
out += ch & 1 << i ? '1' : '0';
return out;
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
<if you="" start="" from="" right="" to="" left,="" looking="" binary="" combination,="" can="" use:
="" div_t="" div(="" int="" numer,="" denom="" );
where="" is="" number="" which="" convert="" into="" binary,="" and="" nuber="" 2.
normaly="" this="" function="" have="" put="" loop="" for="" combination="" want="" (8,="" 16,="" 32,="" 64="" ...)
example:
x="64;" it="" your="" conversation
div_t="" div_result;
for(int="" i="0;" <="" 8;="" i++)
{
="" div_result="div(" x,="" 2="" );
="" if(div_result.rem="=" 0)
="" {
="" '0'
="" do="" what="" want
="" printf(="" "0");
="" }
="" else
="" '1'
="" "1");
="" x="div_result.quot;
" if(x="=" break;
}="">
|
|
|
|
|
Is there a windows message that triggers when data is sent to a port? Thanks a lot.
|
|
|
|
|
|
I'm trying to start an external utility from a C++ program, but I'm having
some problems
I've tried various approches, but all seem to suffer from the same problem:
I can start the utility but if I try to wait for it to exit, then I'll wait
forever (& the utility never seems to start running). One example:
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = _T("open");
ShExecInfo.lpFile = "c:\\xxx\\yyy\\zzz.exe";
ShExecInfo.lpParameters = "REPORTS C:\\xxx\\SK.TXT 0 0/EXTENSION=XY C:\\XXX\\ABC";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
If I single step while debugging, it works OK. If I remove the
WaitForSingleObject call (& show a messagebox asking the user to indicate
when to continue, it works OK.
I've also tried CreateProcess + WaitForSingleObject, but with the same results.
I *think* the utility is a 16bit program, and perhaps this might be an issue.
Any ideas / example code?
Many thanks
Steve Kearon
|
|
|
|
|
Steve Kearon wrote:
I *think* the utility is a 16bit program, and perhaps this might be an issue.
The only way to be sure is to use a known 32-bit program in place of zzz.exe.
Here is some more information.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
your message was a tad enigmatic, but this works perfectly:
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = _T("open");
ShExecInfo.lpFile = "notepad.exe";
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
so maybe the specific utility I'm starting *is* 16 bit.
What voodoo would then be needed?
|
|
|
|
|
Steve Kearon wrote:
your message was a tad enigmatic...
It wasn't clear? How so?
Steve Kearon wrote:
What voodoo would then be needed?
One thing you might try is to use CreateProcess() instead of ShellExecuteEx() . Another, if I remember it correctly, is to use GetModuleHandle() and Sleep() within a while loop in a separate thread. This is what was done on a 16-bit application that I used to work on.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
You'll need to create a file in the SendTo folder:
TCHAR szPath[MAX_PATH];
LPITEMIDLIST pidl;
SHGetSpecialFolderLocation(0, CSIDL_SENDTO, &pidl);
SHGetPathFromIDList(pidl, szPath);
PathAppend(szPath, "my_menu_option.the_name_of_your_app") );
CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
I have TLB of JScript component (.wsc file),
I make Import from it,
and import creates prototype for functions
with one more argument than in JScript "const _variant_t & OptionalArgs"
What I must insert into it, once I newer used it in JScript ??
(zero or just pointer - results ti error "invalid poiter")
Thanks
<br />
inline _variant_t Automation::CreateMenu ( <br />
const _variant_t & strChoices,
const _variant_t & strPrompt,
const _variant_t & nMaxAttempts,
const _variant_t & nTimeout,
const _variant_t & OptionalArgs )
{<br />
<br />
VARIANT _result;<br />
VariantInit(&_result);<br />
<br />
_com_dispatch_method(this, 0x2, DISPATCH_METHOD, VT_VARIANT, (void*)&_result, <br />
L"\x000c\x000c\x000c\x000c\x000c", &strChoices, &strPrompt, &nMaxAttempts, &nTimeout, &OptionalArgs);<br />
<br />
return _variant_t(_result, false);<br />
}<br />
<br />
|
|
|
|
|
I'm not quite sure what you're asking for.
But if you don't want to send any optional args at all, then you could do like this:
<code>
_variant_t strChoices("Some choices");
_variant_t strPrompt("prompt");
_variant_t nMaxAttempts((long) 1);
_variant_t nTimeout((long) 1000);
_variant_t OptionalArgs( (long) DISP_E_PARAMNOTFOUND, VT_ERROR);
myAutomation->CreateMenu(strChoices, strPrompt, nMaxAttempts, nTimeout, OptionalArgs);
</code>
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
I am basically a c/c++ programmer. i want to do some fast application development. i have used raw win32 api, MFC, and c#.net but i dont know which one to stick with. i cant use win32 as its to tedious. MFC, by my personal thinking, is replaced by .net base library and i cant stick to old mfc for vc++ 6. I cant use C# as i want to use c++ instead.
Please i need guidance from you professionals. Pardon any non sence as i'm just an amature in windows programming.
To hit 3rd floors window you have to AIM for 5th or Higher.
|
|
|
|