|
Thanks for your reply !
The app is like 99% complete though and it's pretty complex with a lot of dialogs functions. Could it be converted to a COM DLL in any easy way ?? (I have very limited experience with COM-programming and creating DLL's)
And if not .. could there be any other way ?
|
|
|
|
|
I'm trying to use CORBA, but i don't really understand all the code generated, and the way it proceeds the RPC (if RPC there is...).
Can anyone help please?
ps: if you need more precisions, no problem, just ask me what you want to know
TOXCCT
|
|
|
|
|
Hi!
Having problem with my program. I'm looking up the device, but it will not be found. I'm trying to different ways. I know I have a device. With Tcpdump I can sniff packets at eth0. But my own program do not work.
Does anyone know why it do not work?
Thanksful for your help,
Stefan
My code:
#include <stdio.h>
#include <pcap.h>
int main()
{
char *dev, *device, errbuf[PCAP_ERRBUF_SIZE];
pcap_t *kkk;
dev = pcap_lookupdev(errbuf);
kkk = pcap_open_live(device, 128, 0, 100, errbuf);
printf("Device1: %s\n", dev);
printf("Device2: %s\n", kkk);
return 0;
}
|
|
|
|
|
sorry, can't help you man, you're too less precise
please
- give more details (like what you excpect exactly, and what it does instead),
- be more "readable" (colors, indentations, useful & logical variable names...)
- be careful to the < and > html tags delimiters when you write a C header... (your #include don't appear)
i wish i'll be able to help you, but you have to help me too...
ps:what is pcap ?
TOXCCT
|
|
|
|
|
Hi,
Does anyone know the function that allows a running application to be closed and re-started?
Is it possible to run this function from within the application I'd like restarted?
Thanks in advance
|
|
|
|
|
In a word, no. If you are calling it from your own application, you could call GetModuleFileName to get your EXE name, then CreateProcess to reexecute you, then PostQuitMessage to shut yourself down.
If you want to do it to someone else, then you will need to find the window that you wish to kill, get the related process name for that window, post a WM_CLOSE to that window, or a WM_QUIT to that window's thread, then restart the app.
There isn't, AFAIK, a function that does all this for you.
|
|
|
|
|
Thanks for the reply.
Decided to go antoher route. Just about to implement and test.
|
|
|
|
|
Hi All
Does any one, know of a way to detect if a user is logged to his/her
pc with administrative rights ?
thanks
Simon
|
|
|
|
|
Like this:
BOOL IsAdministrator(void)
{
BOOL fRet = TRUE;
HANDLE hProcess = INVALID_HANDLE_VALUE;
HANDLE hAccessToken = INVALID_HANDLE_VALUE;
UCHAR InfoBuffer[1024] = {0};
PTOKEN_GROUPS ptgGroups = (PTOKEN_GROUPS)InfoBuffer;
DWORD dwInfoBufferSize = 0;
PSID psidAdministrators = NULL;
SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY;
UINT x = 0;
hProcess = GetCurrentProcess();
if(!OpenProcessToken(hProcess,TOKEN_READ,&hAccessToken))
return(FALSE);
if(!GetTokenInformation( hAccessToken,TokenGroups, InfoBuffer, 1024, &dwInfoBufferSize))
return(FALSE);
fRet = AllocateAndInitializeSid(
&siaNtAuthority, 2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &psidAdministrators);
if (!fRet)
return(FALSE);
for(x = 0; x < ptgGroups->GroupCount; x++)
{
if(EqualSid(psidAdministrators, ptgGroups->Groups[x].Sid))
{
FreeSid(psidAdministrators);
return(TRUE);
}
}
FreeSid(psidAdministrators);
return(FALSE);
}
Which will return true if the current user is a member of BUILTIN\Adminstrators group or false otherwise
|
|
|
|
|
IsUserAnAdmin[^] will test whether the user is a member of the Administrators group. This is one of the Settlement Program Interfaces[^], so you may need to use LoadLibrary and GetProcAddress to use it.
However, this only works well in the default environment. An administrator may have assigned rights to other user accounts or groups to give them raised privileges. A better way is simply to try whatever operation needs to be performed, and handle any access-denied errors that occur.
|
|
|
|
|
|
Maybe it was only ever exported by ordinal.
The Settlement Program is something that came out of the anti-trust suit: this is one of the 'revealed' APIs. If you get hold of a recent Platform SDK (December 2002 or later, currently at February 2003), you'll find this function in ShlObj.h. I assume that the appropriate import library (shell32.lib?) contains the necessary import to call the function.
I stand by my earlier statement that this is the wrong way to do it anyway.
|
|
|
|
|
Hello all:
can any one please help me how can I get HGLOBAL for the data contained in CRichEditCtrl ,I've to strore the data as BLOB and the class i am using for BLOB need HGLOBAL for that data..please help me in this context...
Muhammad Ahmed
ahmed
|
|
|
|
|
Use CRichEditCtrl::StreamOut() and write your own stream callback function, in that you copy raw bits from rich edit control to HGLOBAL .
See the EDITSTREAM and CRichEditCtrl documentation for details.
Robert-Antonio
|
|
|
|
|
thanks alot brother..you solved the problem almost 95 %
Regards
Muhammad Ahmed
ahmed
|
|
|
|
|
the callback function is called, passing the data in segments, so should i allocate memory on the heap for each call and the integrate the whole data in a newly allocated memory or is there a way to keep appending data to the buffer allocated only once....(or is there a way to find in advance how much buffer we should have?)
thanks
ahmed
|
|
|
|
|
The callback function takes the cb parameter, which contains required size of CRichEditCtrl data. You can grow the HGLOBAL memory with GlobalRealloc .
Robert-Antonio
|
|
|
|
|
hello every body
I want to know how can i end an sdi application like what we do in the Dialog application by calling CDialog::OnOk()
Best Regards
|
|
|
|
|
I believe the best practice is to post a WM_CLOSE message to your CFrameWnd-derived object. Something like that: AfxGetMainWnd()->SendMessage(WM_CLOSE);
|
|
|
|
|
thank u for it is working now
Best Regards
|
|
|
|
|
Hi!
I want in my program to be able to input text into an edit control and instead of having to move the mouse and click on the button to get the text input, I want it so that when you press enter, rather than closing the dialog, it will work the same as clicking on the button.
Can someone please help?
Thankyou
Ashman
|
|
|
|
|
I have done this some time ago. I don't know exactly how I have done it anymore, but I think I have used CWnd::PreTranslateMessage. If you overload it in your dialog class you can capture the key event before it is sent to the window!
|
|
|
|
|
Hi
I think to deactivate Enter Key u have to cancel OnOk() in the virtual member function like the following:
//////////////////////////////////////////////
void CanyDlg::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
//////////////////////////////////////////////
Best Regards
|
|
|
|
|
Capture the WM_COMMAND message for your default button (lets say here your default button has the ID IDOK) by overriding the relavant function, CYourDialog::OnOk in this case, then rather than calling the base CDialog::OnOk, move the focus to your edit control, either like this:
GetDlgItem(IDC_MY_EDIT_CTRL)->SetFocus();
Or like this:
SendMessage(WM_NEXTDLGCTL, (WPARAM)GetDlgItem(IDC_MY_EDIT_CTRL)->GetSafeHWnd(), TRUE);
The difference between them is the second is usually more suited to moving the keyboard focus around a dialog box as it updats the button borders correctly, so in full:
void CMyDialog:::OnOk()
{
if(CWnd::GetFocus() == GetDlgItem(IDC_MY_EDIT_CTRL))
{
// edit control focused, so do normal stuff
CDialog::OnOk();
}
else
{
// move focus to edit control
SendMessage(WM_NEXTDLGCTL, (WPARAM)GetDlgItem(IDC_MY_EDIT_CTRL)->GetSafeHWnd(), TRUE);
}
}
This will make enter move the focus to the edit control if something other than the edit control is foucsed, or make enter behave as normal if it is the edit control that's focused
|
|
|
|
|
That's all U need in MFC. I know very similar solution in win32sdk. If U need tell?
Cheers!
Siddharth
|
|
|
|