|
|
why don't you just do :
CString str = "hello world";
(LPCSTR)str;
|
|
|
|
|
Thank you very much.
Uday kiran
|
|
|
|
|
what happen if we use inline keyword before main().
is it allowed? if yes how what will be behavior of programm
|
|
|
|
|
inline doesn't enforce the function to be actually inlined.
it's up to the compiler to decide if the function is simple enough.
moreover, the main goel in inlining functions is for earning some call time when the function is called multiple times ; main is called once AVAIK !
|
|
|
|
|
toxcct wrote: main is called once AVAIK !
Unless it is called recursively, which I've seen people do.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
OMG, yes !
|
|
|
|
|
Using the keyword inline before a function does not necasserily mean it will be inline, it is more like a request to the compiler. In the case of main() the request would be declined.
|
|
|
|
|
I have a program that automatically shall send alot of emails through Outlook, and I want to get rid of the warning "A Program is trying to send email..." that pops up everytime you try to send an email.
First of all.. I know there are programs available that I could try and use like "ClickYes" and "Quick-Merge".
However I do not want to rely on another software to do the stuff for me. What I want to do is to add a hook that sees when the security warning dlg comes up and then closes it automatically by pressing the yes buttton before the five seconds are up.
I have tried the following and it almost works:
BOOL CALLBACK EnumAppearanceChildProc2(HWND hwnd, LPARAM lParam)
{
TCHAR buff[512];
GetWindowText(hwnd,buff,512);
if(_tcscmp(buff,_T("Yes")) == 0)
{
*reinterpret_cast<HWND*>(lParam) = hwnd;
return FALSE;
}
return TRUE;
}
HWND GetYesButton(HWND hWndParent)
{
HWND hWnd = NULL;
EnumChildWindows(hWndParent, EnumAppearanceChildProc2,
(LPARAM)&hWnd);
return hWnd;
}
LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HCBT_ACTIVATE)
{
HWND hWnd = (HWND) wParam;
TCHAR buff[512];
GetWindowText(hWnd,buff,512);
if(_tcscmp(buff,_T("Microsoft Office Outlook")) == 0)
{
SetWindowText(hWnd,"Correct Window");
HWND YesButton=GetYesButton(hWnd);
SetWindowText(YesButton,"Correct Button");
EnableWindow(YesButton,true);
Sleep(100);
PostMessage(YesButton,BM_CLICK,0,0);
g_hWndEffects = hWnd;
UnhookWindowsHookEx(g_hook);
}
}
}
In the main program I then call:
g_hook = SetWindowsHookEx(WH_CBT, CBTProc, g_hModule, 0);
This code finds the window and automatically activates the yes button in the security dialogue, but the press command that I send has no effect. If I click the button myself with the mouse the yes button has effect and it can be pressed before the five seconds is up.
Can anybody explain why the press in my code has no effect?
AngryOutlookUser
-- modified at 7:15 Tuesday 23rd January, 2007
|
|
|
|
|
1. edit your message and move your code block into a <pre></pre> tags block
2. why do you add line breaks by hand ?
3. don't do what you're trying to do. this is a security reason. let the user know that your application uses his email id to send mails.
|
|
|
|
|
1. I dont have any pre /pre tags block. Normal C++ code.
2. To make it look nice?
3. It is a user request to add it. The program is sending hundreds of emails. Waiting 5 seconds per email will take considerable time, the problem has to be solved somehow.
|
|
|
|
|
Abris wrote: 1. I dont have any pre /pre tags block. Normal C++ code.
i meant HTML in your message, not in your source code
Abris wrote: 2. To make it look nice?
it doesn't, it breaks the line in the middle of my screen !
Abris wrote: 3. It is a user request to add it. The program is sending hundreds of emails. Waiting 5 seconds per email will take considerable time, the problem has to be solved somehow.
then your application is badly designed. you shouldn't use Outlook for that then...
|
|
|
|
|
1-2. No comments.
3. Nope, not bad design since it is the only option that will work on our system.
|
|
|
|
|
Abris wrote: 1-2. No comments
much better
Abris wrote: 3. Nope, not bad design since it is the only option that will work on our system.
i think some APIs exist to send mails without having a particular client (like outlook) installed. you only have to know how to connect to the SMTP server....
|
|
|
|
|
I have had limited success with these APIs. The ones that I have gotten to work only works for internal email at the firm, when adding outside mail adresses they have all failed. With Outlook solution all mails have successfully reached the destination, but ofcourse with the cost of the security warning.
|
|
|
|
|
Abris wrote: 3. It is a user request to add it. The program is sending hundreds of emails. Waiting 5 seconds per email will take considerable time, the problem has to be solved somehow.
Use MAPI, SMTP, or CDO then. Trying to bypass Outlook's security is a bad idea.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Bypassing security is both a bad idea and a lot of fun. I thought bypassing microsoft security was something that all of us find funny
-- modified at 11:13 Tuesday 23rd January, 2007
|
|
|
|
|
Note the following remarks from MSDN:
If the button is in a dialog box and the dialog box is not active, the BM_CLICK
message might fail. To ensure success in this situation, call the SetActiveWindow
function to activate the dialog box before sending the BM_CLICK message to the button. Note that I have had limited success is using the BM_CLICK message, but often do well using BN_CLICKED - which is a good old fashioned WM_COMMAND based notification.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks for the tip, but unfortunately it does not work even when I add SetActiveWindow(hWnd); to the code or replaced BM_CLICK with BN_CLICKED, the Postmessage just do not have any effect
|
|
|
|
|
Abris wrote: or replaced BM_CLICK with BN_CLICKED,
You cannot just replace BM_CLICK with BN_CLICKED - you have to use WM_COMMAND as the message, the button's HWND as the LPARAM and the button's dialog control ID and BN_CLICKED as the WPARAM , wrapped into a WORD value. Look up the BN_CLICKED notification in MSDN for more information.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Sorry my mistake, should ofcourse have checked the manual before . But even when trying "SendMessage(hWnd, WM_COMMAND, MAKELONG(0x12A6, BN_CLICKED), (LPARAM)YesButton);" which should be the right way to send the message the Sendmessage/Postmessage has no effect on the button (with ActiviteWindow as hWnd). Anyone has more ideas?
|
|
|
|
|
I recently ran into this same problem but for entirely different reasons. I was using this article's[^] code for doing unattended sending of email. After a new XP image was placed on the PC, this program began to fail in a very unpredictable manner. Instead of getting a new image installed which unfortunately can take a lot of time here, I installed a very old version of the program that used simple MAPI and worked just fine with Outlook 97!. The very first time the program got invoked and went to send out about a dozen emails, up popped this dialog. Did I mention that this PC was running unattended Man was I pissed. Anyways, I reverted back to Noel's code and using it instead, does not cause that dialog to come up. If you are presently using something like simple MAPI, you should be able to convert to it easily.
Chris Meech
I am Canadian. [heard in a local bar]
I agree with you that my argument is useless. [Red Stateler]
Hey, I am part of a special bread, we are called smart people [Captain See Sharp]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
Oki, have gotten around the warning dialogue using this class. But the fact that the button still not can be presses is bugging me. Must be a way to press it since there are comercial products out there that does just what I wanted to do, more ideas please
|
|
|
|
|
|
Symantec apparently has a nice library of controls. I've alway likes their UI. I personally
can't stand UI coding so I'd sure like to use their code
Sorry, what was your question again?
Mark
|
|
|
|