|
thakns for response.
I want to do it using my application.
Is there any API or any function which will tell me about my public ip..
|
|
|
|
|
>> Is there any API or any function which will tell me about my public ip.
No.
Think about a typical home setup.
[Your PC] - [DHCP][Cable Modem] - [ISP] - ...
Your PC knows what IP the cable modem DHCP server has assigned it.
It can even find out what the cable modem IP is with respect to your PC.
But, the cable modem has 2 IP's, one on your internal network, and one assigned to it by the ISP.
You would have to query the cable modem (router) to find what IP it has on the ISP side.
This is possible, but generally too much work compared to a quick send/recv to a well-known server.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hello people,
I'd like to know how to declare and use an array of pointer on functions?
Lets say:
<br />
void f1() { ... }<br />
void f2() { ... }<br />
void f3() { ... }<br />
<br />
typedef struct _toto<br />
{<br />
int x, y;<br />
} TOTO;<br />
<br />
TOTO g_toto;<br />
<br />
void InitTOTO()<br />
{<br />
g_toto.x=g_toto.y=0;<br />
<br />
g_toto.functions[0]=f1;<br />
g_toto.functions[1]=f2;<br />
g_toto.functions[3]=f3; <br />
}<br />
<br />
int main()<br />
{<br />
InitTOTO();<br />
for (int i=0; i<3; i++)<br />
}<br />
I hope you see what I wish to do...
Thanks for giving me the clue
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
The functions need to have the same prototype (that is, same return type, same number of arguments of same types).
Then you will need to typedef your prototype (just an example here):
typedef (int)MyFuncPrototype(int, int)
Then you can use your function pointer:
MyFuncPrototype FuncTable[3];<br />
FuncTable[0] = SomeFunction;<br />
....<br />
....<br />
FuncTable[0](5,6);
|
|
|
|
|
one idea is to use a function with a pointer to a class holding you parameters.
typedef (int)MyFuncPrototype(pParamObject)
|
|
|
|
|
See if this thread is of any help.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
in my application, i use some dialogs to update some of the data. I want to add some accelerators. I can add this accelerators in other parts of the application, they work but in dialogs i've a problem. for example when i use Ctrl+A i just got a "beep", it doesn't even "OnEditSelectAll" use this function. How can i use accelerators with Dialogs.
|
|
|
|
|
You can make a dialog use an accelerator resource (say IDR_DLG_ACCELERARATOR) doing the following:
Add the following members to your dialog class:
class CSomeDialog : public CDialog
{
private:
HACCEL m_hAccelTable;
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
Add the following to the dialog constructor
CSomeDialog::CSomeDialog()
{
m_hAccelTable = LoadAccelerators(
AfxGetResourceHandle(),
MAKEINTRESOURCE(IDR_DLG_ACCELERARATOR));
}
Then add the following function implementation:
BOOL CSomeDialog::PreTranslateMessage(MSG* pMsg)
{
if (m_hAccelTable && ::TranslateAccelerator(m_hWnd, m_hAccelTable, pMsg))
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thank you Jose. it worked. A very pratical solution.
|
|
|
|
|
I have a file (d://*.txt)
require :
1.My app(exe) can read ,write ,delete ,update this file;
2.user(you or me) can't write ,update ,delete this file,but he can read this file.
can you give me advise please?
thanks
|
|
|
|
|
Open the file in read-only mode, and keep it open. That way no one can write to, or delete the file.
When you need to write to it, or update it or delete it, close the file handle, then do whatever you want with it.
Have fun.
this is this.
|
|
|
|
|
won't work anymore when closing the application
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Can use a service for that instead of a program.
this is this.
|
|
|
|
|
not a good method.
there's no need to use memory and processor ressources...
NTFS provides rights on the file system, which allow you to set who can and who cannot access the file/directory, and how wide is the authorization for one on that file...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I don't know if it is possible to set access rights for individual programs in NTFS ("not different users"). Like: one program can read modify/delete a file while another cannot?
Maybe you can link to the right source.
this is this.
|
|
|
|
|
To expand on toxcct's suggestion. Deny all access to the file except for one user (a user that is not used by any person). Then in your program, impersonate that user before trying to update the file. See CreateProcessWithLogonW() . Make sense?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I called setBKColor in on draw function but nothing happend, why?
how to use setBKColor function and how to change the background color of the view. any one knows please tell me. thanx a lot.
|
|
|
|
|
Either use:
OnDraw()
{
CRect rect;
GetClientRect(&rect);
pDC->FillSolidRect(&rect,RGB(255,0,0));
}
OR:
Handle the OnEraseBkGnd():
{
CRect rect;
GetClientRect(&rect);
pDC->FillSolidRect(&rect,RGB(255,0,0));
return TRUE;
}
this is this.
|
|
|
|
|
why the function setBKColor doen't work?
how and where share i use this function.
thanx a lot.
|
|
|
|
|
The following code is one of the ways... You would have to read the GDI to understand by SetBkColor won't work (you have to define a context first b4 u use it)
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(&rect); //Obtain the height/width of the window
CBrush brush = CBrush (RGB (0, 0, 255)); //Create a blue color brush
CBrush *pOldBrush = dc.SelectObject(&brush);
dc.Rectangle(0, 0, rect.Width(), rect.Height()); //Fill the client area with the blue rect
dc.SelectObject(pOldBrush); //restore old brush
}
(http://www.dvrshark.com)
Umer Mansoor
|
|
|
|
|
I have a Visual C++ Front-end application accessing a MsAccess databases backend via ODBC.
The app uses CRecordset MFC classes to access the db tables.
After upsizing to SQLServer, the process of opening the database and recordsets takes 75seconds as compared with 0.5seconds in Access! I am amazed, and figure something fundamental is wrong.
I use open type of CRecordSet::snaphot in the CRecordset::Open calls. If I use dynaset instead of snapshot it speeds things up a lot, but then I get problems down the line, fundamentally because I don't think the ODBC driver supports dynasets.
I have added clustered index to the primary key of every table in SQL, and this goes a small way to improving performance but not much.
I still think I have missed something fundamental - I am a newbie to SQLServer so go easy!
Many thanks for any help.
Mark
|
|
|
|
|
We used to have SQL server script code run from a VC project accessing the SQL server through ODBC. That was slower than dripping molasses in a New Hampshire winter.
I switched over to using the ADO classes here on CodeProject and what used to take two hours to run took about 35 seconds.
Do what it takes to lose the ODBC and change to the ADO, you probably won't regret the performance improvement.
|
|
|
|
|
Blake,
Thanks for the reply. I actually started looking into the possibility of ADORecordsets yesterday, so this confirms it would be a wise move, thanks.
I assume I can use these classes in VC++ (as opposed to having to move to .NET) in place of my CRecordsets (obviously with a bit of tweaking throught the code), but in a similar way?
|
|
|
|
|
|
http://img194.imageshack.us/img194/1737/hwnd8ry.jpg
i am trying to post a message to my windowless app
i tried
<br />
PostMessage( theApp.GetMainWnd()->m_hWnd , WM_MAKE_TIME_STOP_DLG, (WPARAM)broken_msg_obj.parm2, 0);<br />
<br />
PostMessage( theApp.m_hThread , WM_MAKE_TIME_STOP_DLG, (WPARAM)broken_msg_obj.parm2, 0);<br />
<br />
PostMessage( hwnd , WM_MAKE_TIME_STOP_DLG, (WPARAM)broken_msg_obj.parm2, 0);<br />
<br />
PostMessage( m_pMainWnd->GetSafeHwnd() , WM_MAKE_TIME_STOP_DLG, (WPARAM)broken_msg_obj.parm2, 0);<br />
<br />
PostMessage( GetParent(0) , WM_MAKE_TIME_STOP_DLG, (WPARAM)broken_msg_obj.parm2, 0);<br />
<br />
PostMessage(this->m_pMainWnd->m_hWnd, WM_MAKE_TIME_STOP_DLG, (WPARAM)broken_msg_obj.parm2, 0);[/CODE]<br />
<br />
but they all either give compile error or dont work<br />
<br />
<br />
my initinstance of the app<br />
[CODE]<br />
BOOL CAsevApp::InitInstance()<br />
{<br />
CDialog dlg;<br />
m_pMainWnd = &dlg;<br />
return TRUE;<br />
}
please asssist :wave:
|
|
|
|