|
HINSTANCE hInst = GetWindowLong(hWnd,GWL_HINSTANCE);
Look up GetWindowLong() in the MSDN Library for usage.
Trust in the code Luke. Yea right!
|
|
|
|
|
I created a stuct in a class and I need a function that returns the pointer to that struct.
I need to be able to access the elements in the structure.
<br />
class MyClass{<br />
struct a {<br />
char arr[10];<br />
double dub[10];<br />
}<br />
<br />
<br />
function that returns the pointer to struct a<br />
void returnPointer(){<br />
return pointer?????;<br />
}<br />
}<br />
-------------------------<br />
<br />
(From another class)<br />
MyClass::returnPointer();<br />
a.arr[1];
Do I need to make a struct in the class that is calling the function in order to access the elements
by casting the pointer to the struct?
As you can see I am a bit lost on how to do this.
sj
|
|
|
|
|
if you asking about syntax
struct MyClass::a* returnPointer(){return pointer?????;}
if you asking what you should return - you need to declare private/protected member of that type and return pointer to it.
|
|
|
|
|
Are you saying that in the class that I call the function from, I need to declare a private struct just like the one in MyClass?
Then call the function and cast it to that private struct pointer?
thanks,
sj
|
|
|
|
|
I am not completely sure what you asking.
what I meant is :
class A
{
public:
typedef struct B{...}B;
const B* getMyDatamember() const {return &b;}
private:
B b;
};
|
|
|
|
|
Hi all, does anyone know how to make an application delete itself? I am making an uninstaller and want to disconnect the memory linkage from the application file, any sites or scraps of info would be appreciated.
Cheers, Alan.
|
|
|
|
|
|
Your a true star John, thankyou very much mate, its exactly what I'm looking for. Most of the articles I've come accross need to reboot before the changes come into effect. Excellent, made my day,
Cheers, Alan.
|
|
|
|
|
Read this (Jeffrey Richter article. See Figure1 in that article)
|
|
|
|
|
I'm working with "bsearch", a binary sort program. I am experimenting a bit for the sake of learning. I have replaced all of the "int" prototypes with "double" to enable decimals. For some reason I get the follwing error message when I compile. I'm sure it's a simple mistake, but I can't find it.
Compiling...
jjjmn.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Exodus\jjjmn.cpp(20) : error C2664: 'bsearch' : cannot convert parameter 5 from 'double (const void *,const void *)' to 'int (__cdecl *)(const void *,const void *)'
None of the functions with this name in scope match the target type
Error executing cl.exe.
pppp.exe - 1 error(s), 0 warning(s)
below is the program...
----------------------------------------------------
/* bsearch example */
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
double values[] = { 10.1, 20.4, 25.6, 40.3, 90.7, 100.4 };
double compare (const void * a, const void * b)
{
return ( *(double*)a - *(double*)b );
}
double main ()
{
double * pItem;
double x;
cout<<"enter your number when ready.";
cin>>x;
double key = x;
pItem = (double*) bsearch (&key, values, 6, sizeof (double), compare);
if (pItem!=NULL)
printf ("%d is in the array",*pItem);
else
printf ("%d is not in the array",key);
return 0.0;
}
-------------------------------------------------------
thanks
VC++ 6.0
|
|
|
|
|
You're a little confused on how the compare function is used by bsearch. The compiler is complaining becuase your compare function is returning a double, not an int. You can not change the return type to double, rather change your compare function to something like :
int compare( const void *a, const void *b )
{
if( *(double*)a < *(double*)b ) return(-1);
if( *(double*)a > *(double*)b ) return( 1);
return(0);
}
...cmk
Save the whales - collect the whole set
|
|
|
|
|
|
DaveE9th wrote:
I'm working with "bsearch", a binary sort program.
Searching and sorting are completely different things. bsearch() searches, and qsort() sorts.
|
|
|
|
|
Hi all !
Does anyone know how to block outgoing connection ??
I need some info to make firewall
Thanks
Good luck VitSoft
My Home
|
|
|
|
|
how can i free memory use by a static linked dll-function. The problem:
i call dynamic an dll function(1). This function call an static linked dll function(2). Now when I try to free the dynamic libary (FreeLibary) I get an errorcode (GetLastError = 6). I think there is a problem with the linked function....
|
|
|
|
|
Error 6 = ERROR_INVALID_HANDLE.
Do you have something like:
HMODULE hModule = LoadLibrary(...);
if (NULL != hModule)
{
fp = GetProcAddress(hModule, ...);
if (NULL != fp)
(fp)(function params here);
FreeLibrary(hModule);
}
|
|
|
|
|
Yes, in my application i use a dynamic call like yours....
But in my dll (first dll) i use a static linked dll (second dll, called from first dll)
|
|
|
|
|
It helps to use common terminology when describing a problem. Implicit linking is done at link time. Explicit linking is done at run time via LoadLibrary(), GetProcessAddress(), and FreeLibrary(). In the case of the latter, be aware of a hazard (from MSDN):
If the DLL has a DllMain() entry point function, the operating system calls the function in the context of the thread that called LoadLibrary(). The entry-point function is not called if the DLL is already attached to the process because of a previous call to LoadLibrary() with no corresponding call to the FreeLibrary() function. Explicit linking can cause problems if the DLL is using a DllMain() function to perform initialization for each thread of a process because threads existing when LoadLibrary() (or AfxLoadLibrary()) is called will not be initialized.
|
|
|
|
|
AnTri wrote:
static linked dll-function
That's the problem. You can free DLL's that you load with LoadLibrary by using FreeLibrary , but libraries that are implicitly loaded (e.g., you don't call LoadLibrary, you just have your DLL linked into your application) are, AFAIK, always loaded.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
hi,
i started a little project and have little knowledge of c++ yet.
can someone explain me the basic steps to get access to the memory area of a certain process and write a few bytes, please?
i'm on win2000 here, but it would be nice if it works in w9x, too.
So, how do i get the base address of a process memory area?
i hope the memory i want to write is not protected, but i'll see.
thx in advance,
raffa
|
|
|
|
|
Some ideas off the top of my head: You can use memory mapped files or DDE or pipes or GlobalAlloc with the GMEM_SHARE flag or use Atoms or window messages.
onwards and upwards...
|
|
|
|
|
Take a look at this article:
http://www.codeproject.com/csharp/minememoryreader.asp
It's c#, but it uses win32 api.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thank you very much, thats the information i didnt find.
(searching the msdn can be pain in the arse
so back to work...
:up:
|
|
|
|
|
anyone know where I can find some coded audio wave compression algorithms? I'm looking to implement a wave compression program and I've found a couple of algorithms, but I'm trying to find a coded example so that I have something to work from.
It should include Predictor, Rice coding, and Lossless compression.
any suggestions are greatly appreciated. thanks!
|
|
|
|
|
Now i have the task to transfer document to PDF. For i should use the Chinese or Japanese font in the PDF, what should i do?
I look up the PDF Reference from Adobe website, but about the font using in the PDF i still do no know very well, especially the Chinese or Japanese font, did everybody know where have the correspoing article or material i could refer to?
Welcome any suggestion!
Thk u for ur help
Good Luck
|
|
|
|