|
I'm having a problem whne I try and register a control that is missing a component. It returns an exception error. It there an exception catch for the GetProcAddress?
Here's my code:
<br />
HINSTANCE dllhandle = NULL;<br />
HRESULT (WINAPI *lpfDllRegisterServer)();<br />
LPSTR pszFileExt = NULL;<br />
HRESULT hr = S_OK;<br />
<br />
pszFileExt = strrchr(pszFile, '.');<br />
if(pszFileExt)<br />
{<br />
pszFileExt++;<br />
if(stricmp(pszFileExt, "DLL") == 0 || stricmp(pszFileExt, "OCX") == 0)<br />
{<br />
dllhandle = LoadLibrary(pszFile);<br />
if(dllhandle)<br />
{<br />
lpfDllRegisterServer = (HRESULT(WINAPI*)())GetProcAddress(dllhandle, "DllRegisterServer");<br />
if(lpfDllRegisterServer)<br />
{<br />
hr = lpfDllRegisterServer();<br />
if(hr != S_OK)<br />
{<br />
CString strMsg("The following component failed to register.\n");<br />
strMsg += pszFile;<br />
AfxMessageBox(strMsg, MB_ICONEXCLAMATION);<br />
FreeLibrary(dllhandle);<br />
return FALSE;<br />
}<br />
lpfDllRegisterServer = NULL;<br />
<br />
}<br />
FreeLibrary(dllhandle);<br />
dllhandle = NULL;<br />
}<br />
}<br />
else if(stricmp(pszFileExt, "EXE") == 0)<br />
{<br />
char szCmdLine[MAX_PATH+1];<br />
sprintf(szCmdLine, "%s /RegServer", pszFile);<br />
<br />
STARTUPINFO startUpInfo = { sizeof(STARTUPINFO),NULL,"",NULL,0,0,0,0,0,0,0,STARTF_USESHOWWINDOW,SW_HIDE,0,NULL,0,0,0}; <br />
PROCESS_INFORMATION ProcInfo;<br />
<br />
CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, <br />
NULL,&startUpInfo, &ProcInfo);<br />
}<br />
}<br />
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi all,
I use SendInput() API function to simulate keyboard events, and it works good for sending one key at a time, however when I try to send ALT+CTRL+DEL keys I dont get anything, here is my code:
<br />
INPUT inKB[3];<br />
<br />
::ZeroMemory(inKB,3*sizeof(INPUT));<br />
inKB[0].type=INPUT_KEYBOARD;<br />
inKB[1].type=INPUT_KEYBOARD;<br />
inKB[2].type=INPUT_KEYBOARD;<br />
<br />
inKB[0].ki.wVk=VK_MENU;<br />
inKB[1].ki.wVk=VK_CONTROL;<br />
inKB[2].ki.wVk=VK_DELETE;<br />
<br />
SendInput(3,inKB,sizeof(INPUT));<br />
<br />
inKB[0].ki.dwFlags=KEYEVENTF_KEYUP;<br />
inKB[1].ki.dwFlags=KEYEVENTF_KEYUP;<br />
inKB[2].ki.dwFlags=KEYEVENTF_KEYUP;<br />
<br />
SendInput(3,inKB,sizeof(INPUT));
I also tried this method:
<br />
KeyDown(VK_CONTROL);<br />
KeyDown(VK_MENU);<br />
KeyDown(VK_DELETE);<br />
<br />
KeyUp(VK_CONTROL);<br />
KeyUp(VK_MENU);<br />
KeyUp(VK_DELETE);
Note that the above functions use SendInput too. I dont know where is the problem??
Also, I need to SendInput the Windows Key to pop-up the start menu, and I also want to SendInput the SystemMenu Key...................
I have headache from this, any feedback is welcome
|
|
|
|
|
Have you tried playing with the Scan Code parameter of the ki member of the INPUT struct ?
~RaGE();
|
|
|
|
|
Hi-
Thanx for ur reply, but what is the wScan variable for? I searched the net and found that in some codes its a VK code, while it is ignored in most codes and set to 0. Also it is not well commented in the MSDN.
wScan
Specifies a hardware scan code for the key. -MSDN
Another point is that if it is a VK code, then i can pass only two keycodes at a time, (one in wScan and the other in wVk member variable) but I need to pass 3 VK codes at once (CTRL+ALT+DEL)????????
I will be grateful if you could offer some code or a link at least.
Regards,
Mohammad
|
|
|
|
|
Try adding KEYEVENTF_EXTENDEDKEY for VK_MENU and VK_CONTROL. Maybe for VK_DELETE too:
static void SetKeyboardInput(INPUT& input, short key, DWORD dwFlags)
{
input.type = INPUT_KEYBOARD;
input.ki.dwExtraInfo = 0;
input.ki.time = 0;
input.ki.wScan = 0;
input.ki.wVk = key;
input.ki.dwFlags = dwFlags;
}
void SendCtrlAltDel()
{
INPUT inKB[3];
SetKeyboardInput(inKB[0], VK_CONTROL, KEYEVENTF_EXTENDEDKEY);
SetKeyboardInput(inKB[1], VK_MENU , KEYEVENTF_EXTENDEDKEY);
SetKeyboardInput(inKB[2], VK_DELETE , 0);
SendInput(3, inKB, sizeof(INPUT));
inKB[0].ki.dwFlags |= KEYEVENTF_KEYUP;
inKB[1].ki.dwFlags |= KEYEVENTF_KEYUP;
inKB[2].ki.dwFlags |= KEYEVENTF_KEYUP;
SendInput(3, inKB, sizeof(INPUT));
}
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks friend,
but it really did not work, even with setting KEYEVENTF_EXTENDEDKEY for the del key. I am really confused and i spent lots of time on this...
Regards,
Mohammad
|
|
|
|
|
I've been investigating this a bit.
Conclusion (short version):
You can't simulate Ctrl+Alt+Del.
Conclusion (longer version):
You can't simulate it as a keyboard sequence.
The proper way to simulate a Ctrl+Alt+Del is posting a broadcast WM_HOTKEY message. However, for that to work, the calling thread must be part of the Winlogon desktop.
You could use SwitchDesktop, but that in turn requires your thread to not have any open window or hook set.
There's a trick to work-around this too, which is published in many places, and is based on the open source of VNC. Basically, it requires spawning a new thread, and since this thread won't have any window or hook, it would in theory be able to switch to the Winlogon desktop and post the WM_HOTKEY. Some window in this desktop would react to the WM_HOTKEY message and respond in the usual way.
However, before calling SwitchDesktop you need to use OpenDesktop to obtain the handle of the Winlogon desktop. Although I'm not sure if this used to work in previous versions, it definitely doesn't work in modern versions. I've tried with WinXP+SP2, and every call to OpenDesktop for "Winlogon", no matter which access rights you request, fails with "access denied". From what I've seen in many forums, it doesn't work for Windows 2000 either.
I've seen claims that this would still work if your process is running as "LocalSystem", but I'm not sure about that.
--
jlr
http://jlamas.blogspot.com/[^]
-- modified at 0:13 Wednesday 31st August, 2005
|
|
|
|
|
Hi!
I have an application where I used Chris Mounders Grid. There has never been any problem until the last windows uppgrade KB893803v2 for Windows 2003.
My application is compiled with Visual Studio .NET 2003 and all code is unmanaged C++ and I have a Resoure-Only DLL with all my application text and dialogs.
In one of my popup dialog I have a CGridCtrl. The text to the header is from my recourse file.
After KB893803v2 uppgade the header text don't show in release mode, but in debug mode it is visible. Even the data filled out in the grid is invisble in release mode, but if I make a Copy Text to my clippboard the information is visible.
Any idea how to solve this problem?
MSc Bertil Morefält
|
|
|
|
|
It is an add-in that embeds tabs into Visual Studio 6 IDE. Just like the tabs in Visual Studio .NET IDE, it provides you an easier way to switch windows in Visual Studio 6 IDE.
Please have a look at my website:
http://www.visual-studio-booster.com/[^]
Your comments and suggestions are appreciated. Thanks!
/*
An easier way to switch windows in visual studio 6 :
http://www.visual-studio-booster.com/
*/
|
|
|
|
|
why don't you post it as an article on CodeProject ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
That's a good idea, thanks!
/*
An easier way to switch windows in visual studio 6 :
http://www.visual-studio-booster.com/
*/
|
|
|
|
|
eh eh, i do my best for beest suggestions
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
oh, i've just realized that it's a shareWare...
can't we benefit the source code ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
I'm sorry that I'm not going to make it open-sourced currently. I suppose that I may change my mind someday
An easier way to switch windows in visual studio 6 :
[Visual Studio Booster]
|
|
|
|
|
toxcct wrote:
oh, i've just realized that it's a shareWare...
Is somobody still writing obnoxious nagshareware these days?
|
|
|
|
|
Is it free like WndTabs[^]?
I have been using WndTabs for many years and it works great. Any reason to switch?
John
-- modified at 23:45 Tuesday 30th August, 2005
|
|
|
|
|
Good Day,
I'm Using Visual Studio .Net.I Am Currently Studying Visual C++.Net.I Have Created A Windows Search Form.I Have Connected The Form To The Database.The Form Has The Following Text Boxes: Surname Name Id No.I Want To Be Able To Type In The Surname And Click Find.It Must Then Search My Database And Return The Name And Id No.I Would Really Appreciate The Code To Do This.
I Appreciate Your Help And Time
In Every Failure There Is Success
|
|
|
|
|
It depends on what kinda database structure you are using really. If you are using ADO.NET it goes something like this:
OnFindButtonClicked()
{
CString str,cmd;
GetDlgItemText(SURNAME_EDITBOX, str);
cmd.Format("SELECT Name,Id FROM yourTable WHERE surname = %s",str);
// here hook to adapter,dataset, datarow, the whole shebang...
SetDlgItemText(ID_EDITBOX,datarow->Item[S"id"]->ToString());
SetDlgItemText(NAME_EDITBOX,datarow->Item[S"name"]->ToString());
}
Honestly, it is really kinda complicated and alot of code. Here's a very helpful tutorial on ado by Mr. Tom Archer at codeguru.com:
http://www.codeguru.com/Cpp/data/mfc_database/ado/article.php/c4287/
I think there's also a data-bind way that uses wizards, but you'll have to ask someone else for that.
|
|
|
|
|
Hi, I'm using vs.net 2003 and I understand that you can create various string tables that automatically switch depending on the default language set in the windows os control panel. I would like to change the default language within my c++ program though. What code do I write to manually switch the string tables? Thanks.
e.g. Say I am using a Japanese OS, and I want the user to be able to alternate between the English version and Japanese version within the program without going to control panel.
|
|
|
|
|
you have to load from the resource table the string table to which you want to switch. then, use CString::LoadString() to get the strings from the table and CWnd::SetWindowText() to change the caption of the controls...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I got the second part, it's the first part i don't know how to do. My question specifically: What's the code to load the proper string table?
|
|
|
|
|
Hi all.
I want to craete a List Control with small images.
I have to use a CImageList to craete the image list to attach to the CListCtrl.
This little images must be only plain color icons, a green icon, red, yellow, etc. The color is given by RGB.
I'm using this code:
...<br />
CBitmap bitmap;<br />
unsigned char buffer [ 16*16*3];<br />
if( !assignColorToBitmap(reinterpret_cast<unsigned char*>( buffer ), 16, 16, <br />
layerColor.Red(), layerColor.Green(), layerColor.Blue() ) )<br />
{<br />
return FALSE;<br />
}<br />
if( !bitmap.CreateBitmap( 16, 16, 3, sizeof( unsigned char ) * 3, buffer ) )<br />
{<br />
return FALSE;<br />
}<br />
int imageIndex = imageList_.Add( &bitmap, reinterpret_cast<CBitmap*>(NULL) );<br />
if( imageIndex == -1 )<br />
{<br />
return FALSE;<br />
}<br />
if( pList->InsertItem( layerPosition, layerName, imageIndex ) == -1 )<br />
{<br />
return FALSE;<br />
}<br />
...
First i create the buffer for the bitmap color, this done by assignColorToBitmap, i have debugged it and it is right.
Second create a bitmap with the previous buffer with parameters:
width = 16
height = 16
Color plains = 3
Bits per pixel = sizeof( unsigned char ) * 3
Then add the bitmap to the image list, without any mask. And finally insert the item with the corresponding image index.
When i run the dialog all the images are black, when i'm using instead green, red, etc ...
No matter the colors i use i get always a black image.
This code works perfectly if i load and icon instead of craete my own bitmap, but it is not useful in this example because i know onlu at runtime waht colors i have to use for the image list.
Any suggestions?
Thanks
|
|
|
|
|
Have you tried to display your bitmap some other way (like in a CStatic ) just to see if your bitmap definition is wrong or if it is the CImageList that makes trouble ?
~RaGE();
|
|
|
|
|
Hello!
I have 2 questions:
1) How do I declare multidimensional arrays (matrices) in C++??? Can anybody describe it in detail? This is probably a very simple thing, isn´t it?
2) If the first problem is working...can I then declare an array as a member-variable, so that I am able to use this array in my whole program?
Thanks for your help!!!
|
|
|
|
|