|
|
Hi,
Now i using the GetProfileStringW to read the values in registry. But before that i must manually create a registry key in regedit and give it a value. If not when run GetProfileStringW, the program will got error.So,is that any way or function can auto generate the registry key in MFC environment?
|
|
|
|
|
Use the registry APIs instead of GetProfileString.
Look at the documentation for Registry Functions[^].
For example, you can create/open registry keys using RegCreateKeyEx , you can read registry values using RegQueryValueEx etc.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Hi All,
I need to implment a callback to a Nonstatic member function of a class.
Which will be invoked through a DLL.DLL is an independent library.No dependency with the class.
I Implemented with a static function. I need to know how it will be for a non static member function.
My code is as follows for static implementation. I need to change it for a non static .Please help.
class CCallbackTester
{
public:
static int __stdcall CompareInts(const byte* velem1, const byte* velem2);
};
int __stdcall CCallbackTester::CompareInts(const byte* velem1, const byte* velem2)
{
int elem1 = *(int*)velem1;
int elem2 = *(int*)velem2;
if(elem1 < elem2)
return -1;
if(elem1 > elem2)
return 1;
return 0;
}
int main(int argc, char* argv[])
{
int i;
int array[] = {22, 1, 3210, 2109, 1098};
Bubblesort((byte*)array, 5, sizeof(array[0]),
&CCallbackTester::CompareInts);
cout << "After the sorting\n";
for(i=0; i<5; i++)
cout << array[i] << '\n';
getch();
}
in DLL Bubblesort is as follows.
void DLLDIR CALLBACK Bubblesort(byte* array, int size, int elem_size, CompareFunction cmpFunc)
{
for(int i=0; i<size; i++)
{
for(int j=0; j<size-1; j++)
{
if(1 == (*cmpFunc)(array+j*elem_size, array+(j+1)*elem_size))
{
byte* temp = new byte[elem_size];
memcpy(temp, array+j*elem_size, elem_size);
memcpy(array+j*elem_size, array+(j+1)*elem_size, elem_size);
memcpy(array+(j+1)*elem_size, temp, elem_size);
delete [] temp;
}
}
}
}
Thanks
San
|
|
|
|
|
A non-static member function is very much dependent on its class.
So you cannot use it for callbacks.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
One way is to do this is like many callback procedures do - they pass along a user specified argument as a void pointer (PVOID). You can pass a pointer to one of your objects as the argument and use a static member of the same class for the callback procedure. Then in the callback procedure cast the void pointer to a pointer to your object and call your member method. As an example, your callback procedure could look something like this :
class YourClass
{
static int CompareCallback( ctchar * item1, ctchar * item2, void *ptr )
{
if( ! ptr )
return 0;
YourClass * pObject = (YourClass *)ptr;
return pObject->Compare( item1, item2 );
}
};
BTW : you can use this technique in a wide variety of callback scenarios like for thread procedures or window enumeration procedures or ...
|
|
|
|
|
Hello,
I have been working with the Watchport/V2 and Eyetoy webcams. All the reolutions and modes work fine with AmCap but I prefer the simplicity of StillCap for quick photos for a youngster's science project documentation.
The default resolution for StillCap seems to be 320x240 for images saved. I would prefer displaying and saving 640x480.
I used the Visual Studio 2003 Resource editor to increase the displayed size for the StillCap dialog box and the two webcam views.
I have poked around through the source code but cannot find where the camera resolution is set. How do I specify the webcam resolution to be 640x480, preferably as the default?
Thanx,
Tom
|
|
|
|
|
HI,
i have a TabCtrl which is created using Create function(using control variable) but not using resource...
Now how can i increase the font inside the TabCtrl
|
|
|
|
|
Have you tried using the WM_SETFONT Message[^]?
::SendMessage(hwndYourTab,WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
|
|
|
|
|
I just wanna know how to share a big file, 3-4G
when using FileMapping, I only can share a file that not bigger than 1.5G
if bigger than that, I got an error of ERROR_NOT_ENOUGH_MEMORY
Thanks!
|
|
|
|
|
What exactly do you mean by share a big file?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I forgot.
It means to share a big file between multi-process
so all the processes can read the file
Thank you!~
|
|
|
|
|
You could use CreateFile[^] with FILE_SHARE_READ|FILE_SHARE_WRITE as its share mode parameter.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
not that problem
when I create a file mapping that the file is bigger than 1.5Gb
the CreateFileMapping return ERROR_NOT_ENOUGH_MEMORY
And I was wondering if I can map a big file (3-4G) to share in one time
that's what I want
for example I have a 3G file and 100 people wanna read it
so I wanna share it
that's the situation
Thank you !~
|
|
|
|
|
Instead of mapping the file to memory, all 100 people can read it from disk using CreateFile and the share flags.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
speed is important
IO is slower than file mapping
that's why I wanna use it
Best Wishes
One day I will get what I wish by working hard
|
|
|
|
|
I would recommend reading the Microsoft article Creating a File Mapping Object[^]
Specifically the 'File Mapping Size' section where it states the following:
The size of a file mapping object that is backed by a named file is limited by disk space. The size of a file view is limited to the largest available contiguous block of unreserved virtual memory. This is at most 2 GB minus the virtual memory already reserved by the process.
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you so much
I read the book Programming Applications for Microsoft Windows by Jeffrey Richter
but biside file mapping
Is there another way to share a big file in one time
I always wanna find a better way
|
|
|
|
|
I think you should re-evaluate your application requirements. Do you *really* need to share 3 Gigabytes of a file between multiple processes? Why not share small sections of the file as needed? Have a look at the sample:
Creating a View Within a File[^]
You could use a similar technique and share 250 megabytes or more of the file at a time.
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you
I'll try that
|
|
|
|
|
I'll second Randor's suggestion - I've used that technique on files about 1GB in size. I actually wrapped the whole mapping thing in a set of custom STL-style iterators that mapped bits of the file in and out on demand.
I've got a half-written article on the subject - I'll have to pull my finger out and finish it
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Just by going thru the link, i understood that, it talks about memory mapping files.
But i think process address space is limited to 4GB in 32 bit windows. (2GB-Process; 2GB-Kernel)
Hence if you need 3GB of space at a point from your application, you maynot be able to address it.
Check for /3GB switch (even though it is not advisable)... which may give you some more information to approach your problem...
As Randor pointed, u may have to unmap and map whenever required.
Selva
|
|
|
|
|
Thank you for reply
I care more about speed
Only one server
almost 3GB index file is to be read by lots of people
you know
No matter how a program is perfect, slow speed still can't be acceptable
Randor's idea is good
I don't know the efficiency in this way
|
|
|
|
|
Hope you are using Win32 API for this purpose.
Windows 32 can maximum support 2xy32(2147483648 bytes) at maximum of 4 GB(2 GB maximum), but practically it is difficult to use the maximun of 2 GB so based on the RAM size and other resources, it varies below 2 GB.
So i dont think it will possible in Win 32 to load more than 2 GB with the default /2 G, to support more than 2 GB use the switch of /G as mentioned below, http://technet.microsoft.com/en-us/library/bb124810(EXCHG.65).aspx[^].
But such design is not good, either read directly from file as mentioned by randor or enable /3G but none of these are fast. Best is need to have maximum physical memory.
http://www.padtinc.com/epubs/focus/common/focus.asp?I=34&P=article2.htm[^]
modified on Tuesday, July 21, 2009 4:50 AM
|
|
|
|