|
Hi Baldwin
Thanks for reply..
I had already seen the getting MAC address using Netbios.
But,i need to get MAC Address using SNMP.
Thanks.
Best Regards,
A.Ilamparithi
|
|
|
|
|
Look at P.J. Naughter class on sntp and see if that might work.
Best Wishes,
ez_way
|
|
|
|
|
Does GetAdaptersInfo() help?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I have problem with sizeof() function in my VC++ 6.0 compiled project
struct A
{
short b;
char c;
}a;
int t = sizeof(a); gives me t=4;
----------------------------------------
I think it have to be 3
struct A
{
char c;
}a;
int t = sizeof(a); gives me t=1; all right
struct A
{
short b;
}a;
int t = sizeof(a); gives me t=2; all right
I think that I have some problem with my project settings but I do not what.
In some other projct the sizeof() works in way a want it gives 3 for the structure above.
Can someoen explan the reason of the sizeof() function behavier.
Thank you in advance,
Seval YILMAZ
|
|
|
|
|
struct elements are aligned to boundaries (particularly word boundaries) to improve performance. Use #pragma pack(push,1) and #pragma pack(pop) to align a struct on byte boundaries:
#pragma pack(push,1)
struct A
{
short b;
char c;
}a;
#pragma pack(pop)
- Mike
|
|
|
|
|
In a program I'm making, a call to StretchBlt seems to take a very long time. But when I run Windows Media Player (or Real One Player) and play a movie file, and then run my program, StretchBlt works great. But then when I close the media player and run my program again, StretchBlt takes a very long time again. Anyone know what's going on?
-any help is appreciated...
|
|
|
|
|
???
Are you sure that that is what is happening???
|
|
|
|
|
Yep. It's driving me crazy! I just tried it again: I run my program, it draws slowly. I run Window Media Player, it still draws slowly. I play an .AVI file in Window Media Player, it draws very quickly. I close Window Media Player, it still draws very quickly. I reload the image after Window Media Player is closed, it draws slowly again!!! (BitBlt works fine, just StretchBlt is slow)
When I use a program called Process Explorer from Sysinternals, it shows Window Media Player loading a bunch of .dlls when it opens a movie file. I was thinking one one those dll somehow makes StretchBlt run faster. I know that sounds weird. I have no idea really...
|
|
|
|
|
Is the problem occuring while your progam is running?
(1) Run Media Player, (2) Run my program.
(2) Run my program, (2) Run Media Player.
The idea here is to determine if the DLL is loaded into memory, if it is loaded in memory some where then the time to load it into your memory space may have been reduced. If it has not been previously loaded by another program then it may take longer.
I recommend that you do not use StretchBlt(), but create a DIB section and then select it into a memory device context. Once it is in a memory device context then you can treat it the same as any other bitmap.
I am in the process of developing a bitmap editor and have found no reason to use StretchBlt().
INTP
|
|
|
|
|
If I have a CWnd pointer - or a handle - how can I determine the type of the control (button, static, etc.)?
|
|
|
|
|
You could try using the GetClassName() API function, it returns the name of the windows class, then you could check for it in a switch for the names of common controls (check MSDN for them).
Another approach for MFC might be using the IsKindOf() function.
Hope this helps.
|
|
|
|
|
Thanx (especially, because it was quick). I just tried GetClassName; it's beauty is, that I don't have to know the class name; I can get it from a known control and compare it later with the unknown (not as if it would be a problem to remember "Button").
|
|
|
|
|
Glad it worked 4 U
|
|
|
|
|
Hello,
My application needs to retrieve data from the socket, and processes it in real time. It is running OK if I don't use thread.
But when I add thread by calling CreateThread() whenever I receive a data buffer, I got problem.
For each thread I created, I call ProcessMessage(). Within this method, I call another dll ProcessData.dll to do the processing for me. And within this dll, I need to open the database c_database.Open(). That's where I got the error string "Connection in use".
The same code is running OK if I don't use thread..
What's the problem? How to fix it?
Please help!
TQD
|
|
|
|
|
Hi, im trying to learn about setting up system wide windows hooks, ibe
written the .dll where the hookproc resides, and a simple test app.
it actually works, as long as i dont try to call the test application from
inside the hook proc, but if i do try to call it, then its not system wide
any more!.
i put the global variables inside the .dll in a shared section like this:
#pragma data_seg(".HKT")
HHOOK hTheHook=NULL; // the hook handle
HNOTFN pTriggerFn=NULL; // Fn to tell the app the hook has been triggered
LPVOID pUserData=NULL; // app specific pointer passed to the above function
#pragma data_seg();
#pragma comment(linker, "/section:.HKT, rws")
to set the hook, the .dll exports a function like this (there is also
another one to remove it), wich is called by the test app:
BOOL DLL_EXPORT SetTheHook(HNOTFN CalledFn, LPVOID UsrDta)
{
pTriggerFn=CalledFn;
pUserData=UsrDta;
hTheHook=SetWindowsHookEx(WH_KEYBOARD, MyHookProc,
GetModuleHandle("HookLib.dll"), 0);
return (hTheHook!=NULL);
}
CalledFn is typedeféd as this
typedef void (CALLBACK* HNOTFN) (WPARAM, LPARAM, LPVOID);
the test app´s main dialog has a static member function with this signature,
wich is passed when the hook is set, so the .dll can "tell" the app when its
been triggered,
the LPVOID passed is the this pointer of the dialog itself, so the static
function in the dialog can cast it to the dialog type, and call other non
static functions.
my hook proc in the .dll is this:
LRESULT CALLBACK MyHookProc(int Code, WPARAM Wparam, LPARAM Lparam)
{
if(Code >= 0)
{
if(pTriggerFn)
pTriggerFn(Wparam, Lparam, pUserData);
}
return CallNextHookEx(hTheHook, Code, Wparam, Lparam);
}
The Problem:
if i compile / run the above, MyHookProc ONLY gets called when the test app
has the focus, if i press any key with the app minimized(not having focus),
it doesnt get called. (not a system-wide hook)
However, if i just remove the call to pTriggerFn(), and place some other way
of knowing its been called like MessageBox(NULL, "I was Called"), then the
hook works as expected! even if the test app doesnt have the focus!
any idea of what im doing wrong??
thanks for reading!
|
|
|
|
|
The problem could be the way you use the user-defined
function as a "callback". Where in your program is
this function defined? Statically, it seems on first analysis.
In order for it to work correctly this function *must* be
inside the hook DLL, otherwise when your hook DLL is
loaded into another process's address space,
the hook procedure will try to call a function that does not
exist in that address space, and "strange things" will happen.
You have to devise some kind of inter-process communication
to get this to work between processes. windows-messages,
events, rpc etc are all valid options.
Just a guess
James
http://www.catch22.uk.net
|
|
|
|
|
Thanks for your answer James, ibe just read Mr J. Newcomer´s article on hooks, and for what i understood, the whole "dll calls back the app by a function pointer" idea wont work, so i went for PostMessage() instead, the app passes its HWND to the dll in the call to set the hook, wich is stored in the dll´s shared section, and in the hook proc, the dll Posts a custom message to the app using this HWND.
Worked like a charm!
Thanks for reading
|
|
|
|
|
Newbie Question.
Ok, I need to write and then latter read multiple lines to a file.
I figured out how to write one line to a file, and I think I am close for multiple lines, but I am just doin something wrong.
char test1;<br />
char test2;<br />
<br />
test1 = 1;<br />
test2 = 2;<br />
<br />
FILE *fp=fopen("Test.startup","w");<br />
if(fp){<br />
fprintf(fp,"%d",test1 test2);<br />
fclose(fp);<br />
}<br />
Well, obviously that isn't working. Latter it is going to be for like 5 vars. So I am going to need to know how to write five vars, and read five vars to and from a file.
I think for reading it will be something like this.
FILE *fp=fopen("Test.startup","r");<br />
if(fp){<br />
int SomeVar;<br />
if(fscanf(fp,"%d",&SomeVar)==1){<br />
}<br />
fclose(fp);<br />
}
Please help.
Thanks,
Josh
|
|
|
|
|
char test1;<br />
char test2;<br />
<br />
test1 = 1;<br />
test2 = 2;<br />
<br />
FILE *fp=fopen("Test.startup","w");<br />
if(fp){<br />
fprintf(fp,"%d",test1 | test2);<br />
fclose(fp);<br />
}<br />
Well that didn't work, the file ended up being "3"
darn.
LOSTTWARE.com
|
|
|
|
|
Why dont you try with fstream instead? i find them to be a lot easier to use.
if you need help using fstreams, take a look in here http://www.cpp-home.com/FileIO_tutorial.php its a good tutorial on them.
hope this helps
|
|
|
|
|
Ok, I am getting closer, still getting errors, but so far I have this,
ifstream OpenFile("VARS.startup");<br />
char line[6];<br />
<br />
while(!OpenFile.eof())<br />
<br />
{<br />
OpenFile.getline(line,6); <br />
<br />
var_toolbar1 << line;<br />
var_toolbar2 << line;<br />
var_toolbar3 << line;<br />
var_toolbar4 << line;<br />
var_LCLWindow << line;<br />
var_OUTWindow << line;<br />
<br />
}<br />
OpenFile.close();
I declared the vars as intergers in the header file, and each line contains a 0 or a 1. The file has 6 lines for now. I need to get each line into it's respectful Var.
LOSTTWARE.com
|
|
|
|
|
1) fprintf(fp,"%d",test1 test2);
How did this compile?
If the line was "fprintf(fp,"%d",test1, test2);" then it would make since.
OH by the way: fopen("Test.startup","w") and fopen("Test.startup","r") assumes that you are loading binary data not text data. Use fopen("Test.startup","wt") and fopen("Test.startup","rt") when working with text file.
If you want to store characters '1' and '2' to a file:
char test1 = '1';
char test2 = '2';
FILE *fp = fopen("Test.startup","wt");
if(fp)
{
fprintf(fp,"%c%c",test1, test2);
fclose(fp);
}
If you want to load characters '1' and '2' from a file:
char test1;
char test2;
FILE *fp=fopen("Test.startup","rt");
if(fp)
{
if( fscanf(fp,"%c%c", &test1, &test2) )
{
}
fclose(fp);
}
From what I have seen, all you need to do is study the documentation for file I/O. I know peaple ar going to throw iostream a you as a suposably better solution. But 90% of the time it is just a wrapper for for what you are doing.
Writing chacaters to a file using fprintf() is ok, but reading them with fsprintf() has (almost always) been a joke.
Before you use iostream you must understand reading a file at the system level (a.k.a. C level).
INTP
|
|
|
|
|
John R. Shaw wrote:
Writing chacaters to a file using fprintf() is ok, but reading them with fsprintf() has (almost always) been a joke.
Someone has actually suggested that reading from a file can be done via fsprintf() ?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Doh!
I was not thinking clearly. I just made some modifications to the sample code that was given. Besides it should not have been fsprintf (does this exist), it should have been fscanf.
INTP
|
|
|
|
|
i have a lot of questions about compliers
would U plz help me
in my case, it's tcc compiler, and i have to program an auto-grader for C language using C++.
and here are my Q.:
Can i convert a .exe compiler (tcc) to a .dll? How?
How can i get the output file from the (tcc) compiler
Where can i find the error codes or ID, so i can change the error messegs?
Thanx,
|
|
|
|
|