|
You'll need to cast it, since change() is expecting an unsigned char * .
Why are you trying to make a one-size-fits-all function?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
can't you write several overloads of the function, which every func receive the right type ?
|
|
|
|
|
RockyJames wrote: i have funtion named change(long lngNo,unsigned char* pData);
where some times i send intger data,float data ,BOOL data as second parameter.How do i convert integer ,float ,BOOL to unsigned char*.
It is very bad practice to write a one-size-fits-all function. If you are trying to do something with the bytes (i.e. send them across a network using sockets), that is one thing, but if you are trying to decrease the number of methods you need to write for a given operation that doesn't involve direct byte transmissions, then this is the wrong approach.
A cleaner way of doing it would be to:
typedef unsigned long ulong;
typedef unsigned char byte;
void change(ulong size, byte* data)
{
}
template<class T> void change(const T& data)
{
change(sizeof(T), (byte*)&data);
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
The function is not written by me,it is one of the function in control.that`s the problem..so how can i send integer ,float ,BOOL in BYTE or unsinged char format.....?
|
|
|
|
|
If you have the ability to refactor the function, you should.
That said, if you are just looking to get something working with it, you can cast anything in memory to a char* (or anything else for that matter) by taking the address of it (note that it is not necessarily safe to do, but is possible):
struct MyStruct
{
};
MyStruct data;
change((char*)&data, sizeof(MyStruct));
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
In C++, how get the value and key in the IDictionary
Thanks.
|
|
|
|
|
Are you referring to the Keys and Values properties?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi I would like to start a powerpoint slideshow from C++ the way it is done by the shell. I think this is possible by using OLE automation but I could not find a good example to help me on the way. I prefere to use slideshow viewer only if this is possible. (don't use powerpoint) I am not using MFC.
Thanks: cool:
|
|
|
|
|
Remco Hoogenboezem wrote: Hi I would like to start a powerpoint slideshow from C++ the way it is done by the shell.
Then use ShellExecute() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Is it possible for me to link an SDI in my dialog based application? For example, when a button in the dialog is clicked, an SDI window comes up.
I've tried to 'File->Add->New Project' and added an SDI project into my current project but i have no idea how to link them up.
|
|
|
|
|
You mean start a new application (which is a SDI) ?
If yes, take a look at the FAQ[^]
|
|
|
|
|
No, not opening a different application but opening an SDI window from an SDI project which i included in my current Dialog based project
|
|
|
|
|
From your first post:
cv_k3n wrote: I've tried to 'File->Add->New Project' and added an SDI project into my current project but i have no idea how to link them up.
This will simply create a new project (so, a new executable) that will be added in your solution. They are unrelated and the only way to 'link' them is to have one execute the other one. So, this is not the solution.
I don't know how you could do this but you'll probably have to do everything manually (create a frame window, create the view and the document, ...). But I'm not sure if this will work.
|
|
|
|
|
cv_k3n wrote: No, not opening a different application but opening an SDI window from an SDI project which i included in my current Dialog based project
What you will want is to create an SDI application and display your dialog prior to displaying the SDI's mainframe (you'll be making some changes to the app's InitInstance method).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
how shall i start the dll hooking application
naresh
|
|
|
|
|
See and read about SetWindowsHookEx API
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
how shall i start a dll for hooking that will trace the client data and gets the data
naresh
|
|
|
|
|
u can use SetWindowsHookEx api.
u have to specify what type/id of Hook like Keyboard,GetMessage (for more info go to msdn and type setwindowshookex).
Then according to the hook type the hook procedure prototype changes.
export the hook procedure using
__declspec(dllexport) LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// here u can write the code.
// At last u have to call CallNextHookEx
// The handle returned by SetWindowsHookEx has to be passed to this module through another exported function or some user defined messages.
}
//
Regards
Sudeesh
|
|
|
|
|
hi all i had made the service in vc++6. now i want that when that service is installed it start automatically,i had used SERVICE_AUTO_START parameter in the createservice API but it does not start when that function is executed.
Tasleem Arif
|
|
|
|
|
As I understand it that flag only means the service will automatically start up on boot, not necessarily as soon as you install the service. You'll need to start the service yourself manually once you've installed it, with StartService.
|
|
|
|
|
Hello,
I have created an application in vc++, using mfc. I have to create the setup file for the application.
I am confused as to what files to include in the setup. When I run the program in 'Release' configuration, I get the .exe file. Now, I ran this exe file on win98 and xp. It works perfectly.
SO, how do I find out what dll to package with my application?
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
Build your 'exe' by setting 'Use MFC' option to 'Use MFC in a Static Library'...
To set this...go to project properties.. Choose General and set the 'Use MFC' option
Do your Duty and Don't expect the Result
|
|
|
|
|
Open your .exe in Depends and view the list of DLLs it depends on. Depends can be found in Programs | Visual Studio 6.0 | Microsoft Visual Studio 6.0 Tools.
/ravi
|
|
|
|