|
benjnp wrote:
Which is faster when doing a file search on your pc programmatically? CRC's or byte-for-byte checking?
Offcourse CRC, but what the use of that in file search
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hello
I am experimenting with simulating a key press using the SetKeyboardState
<br />
while(true)<br />
{<br />
<br />
DWORD thread_acum=GetWindowThreadProcessId(GetActiveWindow(),NULL);<br />
<br />
UINT vk,scan;<br />
<br />
LPARAM lparam;<br />
<br />
vk = VkKeyScan('s');<br />
<br />
<br />
AttachThreadInput(thread_acum,GetCurrentThreadId(),TRUE);<br />
<br />
<br />
BYTE byKeybState[256];<br />
GetKeyboardState(byKeybState); <br />
byKeybState[vk] =! (BOOL)::GetKeyState(vk);<br />
<br />
<br />
byKeybState[vk] =!(BOOL)GetKeyState(vk);<br />
SetKeyboardState(byKeybState);<br />
<br />
<br />
<br />
<br />
AttachThreadInput(thread_acum,GetCurrentThreadId(),FALSE);<br />
<br />
<br />
<br />
<br />
Sleep(1000);<br />
<br />
}<br />
why does this not work? No key is pressed
|
|
|
|
|
Spiritofamerica wrote:
SetKeyboardState
Why Don't you use SendInput Api or KeyBD_event api..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
because I have the latest version of zonealarm installed on my sytem and it doesn't allow these functions any more
I am not trying to do anything illegal with this but I saw it in a article and said hey I should try this
and it doesn't work
So far za doesn't object to me using this function but it doesn't work
for the others you mention above and for PostMessage(WM_KEYUP) it gives me worning messages
so there are 2 reasons
1. I don't wanna upset za
2.I wanna do it with this function
|
|
|
|
|
hi, all
Windbg supposed to the default debugger on my machine, but when the app is hang, I could get this message "Cannot debug pid 1784, Win32 error 87 The Parameter is incorrect"......why is that?
If I open windbg and attach the process, it would work, so for this app, Dumping objects ->
{360} normal block at 0x00F01F58, 38084 bytes long.
Data: < `Ce v > 88 00 00 00 60 43 65 00 8C 76 13 00 00 00 00 00
{359} normal block at 0x00F01F10, 18 bytes long.
Data: <data\customer.db> 44 61 74 61 5C 43 75 73 74 6F 6D 65 72 2E 64 62
{358} normal block at 0x00EF0878, 100 bytes long.
Data: < !e v > 04 21 65 00 88 00 00 00 10 1F F0 00 8C 76 13 00
{160} normal block at 0x00EF92F8, 35004 bytes long.
Data: <} `Ce 4z > 7D 00 00 00 60 43 65 00 34 7A 13 00 00 00 00 00
{159} normal block at 0x00EF04D8, 17 bytes long.
Data: <data\sysfile.dbf> 44 61 74 61 5C 53 79 73 66 69 6C 65 2E 64 62 66
{158} normal block at 0x00EF0440, 100 bytes long.
Data: < !e } 4z > 04 21 65 00 7D 00 00 00 D8 04 EF 00 34 7A 13 00
Object dump complete.
eax=00000000 ebx=7ffdf000 ecx=000c4006 edx=00000000 esi=77f8ee04 edi=00000000
eip=77f8ee0f esp=0012fe50 ebp=0012ff18 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246
ntdll!NtTerminateProcess+0xb:
77f8ee0f c20800 ret 0x8
0:000> ~
. 0 Id: 984.7bc Suspend: 0 Teb: 7ffde000 Unfrozen
0:000> kb
ChildEBP RetAddr Args to Child
0012fe4c 7c5969e4 ffffffff 00000000 001358f8 ntdll!NtTerminateProcess+0xb
0012ff18 0046470f 00000000 00ef8024 0012ff3c KERNEL32!ExitProcess+0x72
WARNING: Stack unwind information not available. Following frames may be wrong.
0012ff28 004645c0 00000000 00000000 00000000 AddSurchrg!CDate::operator--+0x26f1f
0012ff3c 0045e312 00000000 001358f8 0012f5a4 AddSurchrg!CDate::operator--+0x26dd0
0012ffc0 7c59893d 001358f8 0012f5a4 7ffdf000 AddSurchrg!CDate::operator--+0x20b22
0012fff0 00000000 0045e1e0 00000000 000000c8 KERNEL32!BaseProcessStart+0x3d
looks like the memory leak happened before it crashes, but couldn't tell why is it crashing beside the memory leak. thank you!
|
|
|
|
|
Hello,
I am working on a project and I am stuck at one place. I have 2 applications.
1-> ActiveX Control (Developed in MFC)
2-> A Windows C++ application.(No MFC...purely Windows)
How can I use the functions defined in ActiveX into this C++ application. I tried adding the ActiveX header file in my C++ application but then I get an error of CWnd, CString etc classes of MFC not found.
Please let me know if you or any of your friends know the solution. Please email me at dubeyashok@yahoo.com
Thanks in Advance.
Ashok Dubey
Ashok
|
|
|
|
|
Ashok,
I'm no expert yet on mfc, but from what I've seen, mfc is nothing more than a bunch of wrapper code around the win32 functions. So, I don't think there is any reason why you cannot do this. I would suggest creating a dummy mcf application with ActiveX support. Take a look at the stdafx header file. Also, there your Windows app must call AfxEnableControlContainer(); You'll see all of this in your dummy application.
You should get pretty far with this approach.
chg
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
Hi.
You can access its methods as you would access any other COM object's methods.
Use CoCreateInstance to create the object (based on its CLSID)and that will give you a pointer to the object's IDispatch interface.
Ex:
IDispatch* pDisp;
CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, &pDisp);
clsid is the Class ID for the ActiveX object and iid is the Interface ID for the IDispatch interface of the object.
After that you can use pDisp->GetIDsOfNames() to get dispatch ids based on method names, and with that dispatch id you can use pDisp->Invoke() to call the method.
Remember to call pDisp->Release() to decrement the reference counter for that interface so the object can be destroyed.
|
|
|
|
|
I am trying to call a VB function from VC++ which resides in a VB dll (using CreateDispatch and header from a type library to access the VB dll) that is declared as a "String" and then set the return value to some type of variable that will hold it in the VC++ calling code. I am able to make this handshake and display a messagebox and grab the integer value returned in another test function, so I know that I am talking to the dll, I think it is the darned string representation that is not straightforward.
I have tried to work CString, BSTR, using strcpy, = , whatever and have looked high and low for an example but cannot find what I want.
Does anyone know how to do this?
The generated cpp file present in the VC code that comes from the VB dll contains:
CString _ReadWritePath::LogPath()
{
CString result;
InvokeHelper(0x60030007, DISPATCH_METHOD, VT_BSTR, (void*)&result, NULL);
return result;
}
I am including the header file clslib14.h in the file doing the call,
and the VC++ call is:
_ReadWritePath p;
p.CreateDispatch("ClsLib14.ReadWritePath");
???????? = p.LogPath() // this is what I can't figure out
Effectively, how do I pass a VB's function return value (declared as String in VB 6 as a dll) to a call from VC++ 6 and set it to a local variable in the C++ code?
-Kirk
|
|
|
|
|
Kirk Woller wrote:
Effectively, how do I pass a VB's function return value (declared as String in VB 6 as a dll) to a call from VC++ 6 and set it to a local variable in the C++ code?
I believe you have to use a VARIANT for this.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I have done this but with out using invoke or com. I had a plain C++ DLL that I pased the address of a VB function into. As long as you declair the function pointer comming from VB as pascal works fine.
|
|
|
|
|
Try LPCSTR / LPSTR or _bstr_t any one of those will work. I Regularly use LPCSTR for passing strings into a C++ DLL.
-------------------------------
DEBUGGING : Removing the needles from the haystack.
-- modified at 2:37 Thursday 15th September, 2005
|
|
|
|
|
hi, all
I would get 0xC0000005: Access Violation, at the end of this code:
void Run(LPVOID dat)
{
CAddSurchrgDlg* cDlg = (CAddSurchrgDlg*)dat;
CString csWintext;
cDlg->GetWindowText( csWintext );
csWintext += " Version 1.02";
cDlg->SetWindowText( csWintext );
try
{
if ( !cDlg->m_bCanceled )
cDlg->ParseCommandLine();
if ( !cDlg->m_bCanceled )
cDlg->OpenFiles();
if ( !cDlg->m_bCanceled )
cDlg->AddNewSurcharges();
}
catch( ExceptionMsg e )
{
MessageBox( GetFocus(), e.errMsg, "Add Surcharge", MB_OK | MB_ICONSTOP | MB_SETFOREGROUND );
}
catch (CDataBaseException& e)
{
MessageBox(GetFocus(), e.what(), "Add Surcharge", MB_OK | MB_ICONSTOP | MB_SETFOREGROUND);
}
catch(...)
{
MessageBox( GetFocus(), "Unhandled Exception", "Add Surcharge", MB_OK | MB_ICONSTOP | MB_SETFOREGROUND );
}
cDlg->Exit();
on /MFC/THRDCORE.CPP, It crashes over here:
DWORD nResult = 0;
if (pThread->m_pfnThreadProc != NULL)
{
nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
but if I use the same data and same switch to run this app on command prompt, it would work fine and create reports.....well, i just ran again, it crash, too. so it was just lucky to work sometimes.
anybody get idea why is that? Thank you!
-- modified at 15:54 Wednesday 14th September, 2005
|
|
|
|
|
valerie99 wrote:
cDlg->GetWindowText( csWintext );
cDlg->SetWindowText( csWintext );
This is a major no-no for a secondary thread to directly access a UI component that it does not own. The proper method is to post a message to the thread that owns the UI component. See here and here for more.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
but the access violation message still show up, in fact, it's a bit strange to me, seems like half of time, it would be memory leak and half of times would be access violation.
not sure if they are related...thanks for your time
|
|
|
|
|
what boolean operation does an AND gate and 2 NOR gates compute?
|
|
|
|
|
Isn't it AND ? Doesn't NOR reverse itself ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Oh good grief - are you too lost to even try and find the info?
You have heard of google? By me a donut and I'll tell you out right....
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
Shantise2003 wrote:
boolean operation does an AND gate and 2 NOR gates compute?
Let A and B are two Digital Output NOW.....
A AND B Output
1 1 1
1 0 0
0 1 0
0 0 1
and about NOR A and B or ( A OR B = Output and THEN NOT the output)
A OR B Output NOT modified Output
1 1 1 0
1 0 1 0
0 1 1 0
0 0 0 1
hope this will brush up your mind
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Congratulations on your neat reply - guide the questioner but don't give the answer!
|
|
|
|
|
I wrote an app that will alert me when something happens after a certain amount of time. The app will also dump a file in a directory when it pops up with my alert message. The only problem is, it doesn't alert me if I minimize the dialog. It may still dump the file, I haven't been able to test that yet, but I want my app to still alert me and output this file even when minimized. Any help?
Thnx,
Danny
|
|
|
|
|
Can we see some code?
I've written apps along the same lines without an issue, regardless of being minimised (to the task bar or the system tray). If we can see some code maybe we can investigate.
How is the thing being triggered? An event / message / timer checking for "x" / thread checking for "x" etc.?
-Dy
|
|
|
|
|
When the dialog is created I use CWnd::SetTimer(0, 60000, NULL); and then I catch it with:
void CNewNotifyDlg::OnTimer(UINT nIDEvent) <br />
{<br />
OnRefresh();<br />
<br />
CWnd::SetTimer(0, 60000, NULL);<br />
<br />
CDialog::OnTimer(nIDEvent);<br />
}
OnRefresh() is my function to do my calculations and see if I should notify the user. I want this to run in the background, minimized the majority of the time, and then, if my app's logic dictates, I notify with AfxMessageBox("Hey, wake up!");
I didn't actually see the AfxMessageBox until I maximized the dialog (after I was informed that I had forgotten to do something in the office within a certain amount of time, Arrggh! ).
Danny
|
|
|
|
|
bugDanny wrote:
I didn't actually see the AfxMessageBox
Your timer is being called. Try turning your speakers on - you should hear a beep with each message box each time the timer is executed. The message box however, is in the foregound of your app, and your app is minimised - so you don't see it. (Your data file is still being written out right?)
You could do this:
if (IsIconic())<br />
{<br />
ShowWindow(SW_RESTORE);<br />
}<br />
in your timer, it will restore your dialog. Personally I don't think it's good form to be bringing windows up in front of the user like that, I'd rather minimise to the system tray and maybe use a balloon tooltip as a notification. You might want to have a look around this site for examples of that.
Again, should you be new to this... you don't need to call CWnd::SetTimer(0, 60000, NULL); in your OnTimer (and you don't need the CWnd:: bit in the first SetTimer call...)
-Dy
|
|
|
|
|
bugDanny wrote:
AfxMessageBox("Hey, wake up!");
Use MessageBox instead of the AfxMessageBox version. This should get you the desired results.
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|