|
Disregard my last post about recv()...my meds are making me way too fuzzy
Ok, I was able to compile and run it and everything worked fine after a couple of changes. The first problem is with the CHECK() macro:
#define CHECK(iStatus) \
if(iStatus==SOCKET_ERROR) return 0;\
if(iStatus==0) return 0
DO NOT DO THIS! When this macro is expanded by the preprocessor the send or recv operation passed as iStatus will be executed twice:
if(::send(hSock,sz,strlen(sz),0)==SOCKET_ERROR) return 0;
if(::send(hSock,sz,strlen(sz),0)==0) return 0
Instead you might try something like this (until you get everything fixed):
#define CHECK(iStatus) \
{ \
int result = iStatus; \
if(result==SOCKET_ERROR) return 0; \
if(result==0) return 0; \
}
Every email client I tried did not like the date format included in the message header. The following change should work:
::GetDateFormat(0x409,0,0,T("dd MMM yyyy"),wa,200);
I am a lean mean ground beef machine!!!
|
|
|
|
|
I was wondering how to intercept a WM_ specific message into a C++ class, I need to use the RegisterDeviceNotification function to register a specific WM_ message (I need a window here right?) and then intercept it and call the appropriate function
The C++ class should be included in any project, from a console one to a win32 to a mfc one. My idea is to create the skeleton of a win32 window and then use the WndProc for that window, is this stupid?
Is there any (surely) better solution?
---
|
|
|
|
|
You definitely need to have a Window Proc to recieve your message, because it is associated specifically with a registered Windows class. The documentation over at MSDN should show you how. See this: Windows Procedures Overview[^]
You can also define your own custom Windows messages using a define, and by selecting a value above WM_USER.
|
|
|
|
|
an own WinProc is the generic solution. But be aware that it dont gets "spaghetti ocde"
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
If I put the WinProc function in my class, it will need a hwnd handle I think.
What handle am I supposed to give it? Should I require one to the application which is going to use my class? (this would exclude console apps, that's just a pity)
---
|
|
|
|
|
yes you need a hwnd for it. The main hwnd of the app is fine.
If you havent a hwnd in your app, you must create one. It is common use to have in this cases an invisible (or minimized) window. Believe me
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Ok the invisible window seems the right way.
Thank you all guys
---
|
|
|
|
|
One approach would be to store all message processing objects in a std::map<> container. Although this will only give you a 1 to 1 relationship between the expected window message and the object which handles it you'll have a nice start to begin expanding. When you receive the device notification message you can retrieve the object for that message and then call the appropriate method to handle the operation.
void HandleDeviceMessage(UINT msg, WPARAM wParam, LPARAM lParam)
{
ProcObject *obj;
std::map<UINT, ProcObject*>::iterator iter;
iter = m_DevNotifyMap.find(msg);
if(iter == m_DevNotifyMap.end()) {
return;
}
iter->second->OnNotification(msg, wParam, lParam);
}
I am a lean mean ground beef machine!!!
|
|
|
|
|
Recently, I develop Internet Explorer browser extension.
To put it concretely,
During Browser Extension[^], I applied Adding Button[^] to launch for my application (aka MyApp).
After installation, I could not see MyApp button in IE7, IE8 default toolbar because new extension button attached last position in toolbar.
So, I want to ask to customer after installation and arrange MyApp button to first in toolbar. like below
"Can I arrange MyApp's button to first order in toolbar ?"
But, I don't find any idea, method that control browser button order in toolbar.
(I try to find button order information in registry and to control browser event.)
Anybody have idea?
ref msdn
Browser Extension[^]
Addinb Button[^]
|
|
|
|
|
I'm automating Word and when I call a function that doesn't return for a long time (for example a call to
app.Run(_T("FilePrint")); ) it tends to freeze the UI of my app until it returns from the call, so I tried to run this code from a worker thread, but then COM complains and throws an exception RPC_E_WRONG_THREAD - "0x8001010E: The application called an interface that was marshalled for a different thread."
How can I solve this problem?
btw, there's an explanation about RPC_E_WRONG_THREAD in MSDN - INFO: Explanation of RPC_E_WRONG_THREAD Error[^], but I couldn't figure out anything from it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Could you do all of the automation, including creation of the Word object, on the worker thread?
Basically you're running foul of COM single-threaded apartments and things, I think. This article[^] explains them well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I read the article about apartments and replaced CoInitialize(NULL); with CoInitializeEx(NULL, COINIT_MULTITHREADED); in both my threads, but it still gives me the exact same error "The application called an interface that was marshalled for a different thread."
It's not really necessary for me to use multiple threads, I'm just doing it because I don't want my UI to block while I'm waiting for the COM method call to return. Do you know if there is some way to make a non-blocking COM method call akin to PostMessage vs SendMessage (I might post this as a new question on the forum btw).
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: It's not really necessary for me to use multiple threads, I'm just doing it because I don't want my UI to block while I'm waiting for the COM method call to return
Which is commendable...
sashoalm wrote: Do you know if there is some way to make a non-blocking COM method call
This[^] is the only thing I remember - and that a) needs support from the COM server (Word doesn't provide it) and b) can't handle automation interfaces (which is probably one reason WHY Word doesn't provide it).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
[I could have sworn I'd posted this message before...]
I've been playing with a little Excel automation sample I've got, adding a) Word automation, and b) multi-threading to it. I've ended up with this code that a) creates a Word instance on the main thread and b) calls that Word instance on a different thread. And the call succeeds, returning the expected value!
#include <boost/thread.hpp>
#import "libid:00020905-0000-0000-C000-000000000046" version("1.6") auto_search no_dual_interfaces rename("RGB", "wordRGB") rename("ReplaceText", "wordReplaceText") rename("FindText", "wordFindText") rename("ExitWindows", "wordExitWindows")
void GetActiveDocName(Word::_ApplicationPtr const& wd, _bstr_t& name)
{
try
{
name = wd->ActiveDocument->Name;
}
catch(_com_error& e)
{
name = L"No name";
}
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(0, COINIT_MULTITHREADED);
{
Word::_ApplicationPtr wd;
if (SUCCEEDED(wd.CreateInstance(__uuidof(Word::Application))))
{
wd->Documents->Add();
_bstr_t name;
boost::thread getName(GetActiveDocName, boost::cref(wd), boost::ref(name));
getName.join();
std::cout << (char*)name << std::endl;
}
}
CoUninitialize();
return 0;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello!
I'm trying to make an internet monitoring application to log all the URLs visited by the user. Something like http://www.ematrixsoft.com/website-spy-monitor-software.htm
I tried using a sniffer library as suggested at http://www.codeproject.com/KB/IP/URLLogger.aspx
but had problems with HTTPS URLs because it seems that no only the content of the page is encrypted, but also the URL itself.
Do you have an idea of a "simple" method to catch all the visited URLs from any browser?. I can use a library (Free or not) if necessary.
Thanks.
|
|
|
|
|
televes wrote: Do you have an idea of a "simple" method to catch all the visited URLs from any browser?
No. Encryption is used to prevent exactly what you are trying to do. Since the URL may contain arguments for a GET operation the request and response headers are also encrypted. Attempting to subvert this is typically frowned upon as it becomes a potential exploit for use by Spyware.
I am a lean mean ground beef machine!!!
modified on Thursday, August 13, 2009 6:40 PM
|
|
|
|
|
|
No, not in the middle, in the client machine. In fact, I have discovered a library to do this:
http://www.komodia.com/index.php?page=interceptor.html
|
|
|
|
|
You don't need any library.
Just use COM (Notifications)
|
|
|
|
|
I have created MSI package of my product - using Install Shield 12. The package contains several redistributable files included - partially, Visual Studio 2005 ones.
A customer sent me the following complaint:
"We use corporate version of Norton Antivurus. After installation of your product, any right click on any folder in Windows explorer and many other interactions with Windows cause a prompt of installing missing Norton Antivirus components."
Does someone have any idea what is reason of the problem?
|
|
|
|
|
Sounds like you may be installing older versions of a redistributable file that Norton relies on. The first thing I would check is the file versions and then move to make sure that any files you are installing into the System32 folder actually belong there.
I am a lean mean ground beef machine!!!
|
|
|
|
|
Hi! I am using Visual Studio 2008, and am trying to put some custom code into a DLL whose source code is supplied by a third party. The third party code compiles fine, and everything is fine until I write a piece of code that calls rand(). At that point, when I compile, I get the error message:
error LNK2019: unresolved external symbol _main referenced in function __tMainCRTStartup (file is LIBCMT.lib).
I tried excluding that lib from the link, but that caused a bunch of other errors. Does anyone know how to resolve this problem?
|
|
|
|
|
The only reason that the C runtime should look for 'main' is if it thinks you're building an EXE. Make sure your project properties do actually say your building a DLL...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I checked that; it does indeed think it is a DLL, and in fact it makes a DLL quite happily when I comment out the lines that call rand().
|
|
|
|
|
Hi,
Do you have /GS (Buffer Security Check)[^] enabled? Can you disable this setting and let me know if your problem is fixed?
Thanks,
-David Delaune
|
|
|
|