|
Hello,
I am facing with a problem while trying to allocate very large memory by AWE APIs on Windows 2003 Advanced Server. I developed following code in order to allocate large memory portion, but I couldn't allocate it;
#include "stdafx.h"
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
#define MEM_ALLOC 1024 * 1024 * 1024 * 4 // allocate physical memory
int _tmain(int argc, _TCHAR* argv[])
{
struct {
DWORD count;
LUID_AND_ATTRIBUTES privilege[1];
} info;
HANDLE token=0x0;
BOOL result=FALSE;
int iPageCount=0x0;
int PFNarraysize=0x0;
ULONG_PTR NumberOfPages=0x0;
ULONG_PTR* PFNarraylist=0x0;
SYSTEM_INFO sys_info;
PVOID lpMemoryWindow=0x0;
// get system page size
GetSystemInfo(&sys_info);
// calculate how many pages required
iPageCount = MEM_ALLOC / sys_info.dwPageSize;
// PFN requested size
PFNarraysize = iPageCount * sizeof(ULONG_PTR);
// allocate array for PFN array
PFNarraylist = (ULONG_PTR*)HeapAlloc(GetProcessHeap(), 0, PFNarraysize);
// ------------------------------------------------------------- //
// check user privileges in order to lock memory on the system
result = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
// set privilege attributes
info.privilege[0].Attributes = SE_PRIVILEGE_ENABLED;
// lookup user privileges
result = LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &(info.privilege[0].Luid));
// info count
info.count=0x1;
// retrieve user privilege
result = AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES)&info, 0, NULL, NULL);
// close token handle
CloseHandle(token);
// ------------------------------------------------------------- //
// create memory window
lpMemoryWindow=VirtualAlloc(NULL, MEM_ALLOC, MEM_RESERVE | MEM_PHYSICAL, PAGE_READWRITE);
NumberOfPages = iPageCount;
// allocate physical memory - I
result = AllocateUserPhysicalPages(GetCurrentProcess(), &NumberOfPages, PFNarraylist);
// map user physical page to the window - I
result = MapUserPhysicalPages(lpMemoryWindow, iPageCount, PFNarraylist);
// use memory
lstrcpy((LPSTR)lpMemoryWindow, TEXT("OGED"));
}
In the example that I wrote above can allocate 2 gb or less memory but not more and I am sure that I have 16 Gb physical memory.
How can I allocate and use more than 4 Gb memory? Can anybody give an example about AWE?
PS: I am aware about MSDN AWE and MSDJ - 99 examples, but they are not a solution for my case.
Regards,
Orkun GEDiK
SAP R/3 Software & System Support Specialist
ASTRON
|
|
|
|
|
You do not say it or not, but are you booting with the /PAE switch? You need it to enable applications to address at and above 4GB. Normally, you can only address 2GB unless you booted with the /3GB switch.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hello,
Sorry, I forgot to say that, "I am using /PAE switch already".
Regards,
Orkun GEDiK
SAP R/3 Software & System Support Specialist
ASTRON
|
|
|
|
|
Codeguru,
I have a property sheet, which contains a nmber of property pages. One of the pages contains a CTreeCtrl.
The tree control is used to display a list of items with tick boxes. The list of items never changes, however the ticks next to then respond to changes in the document structure.
I use OnInitDialog to create the list of elements using InsertItem and also log the handles for later use.
I then use OnSetActive to record each time the user clicks the page and update the tick boxes using SetCheck and the recorded handles from OnInitDialog.
My problem:...
The property page has to be shown twice, first the items appear and second the tick boxes are correct. Thereafter everything works fine.
I'm presuming this is because the inserted items have not been activated until after the page is made visible? Therefore SetCheck doesn't do anything on the first pass. But I've tried to resolve this with a call the the property sheet to call another page, using SetActivePage(*), then reactivating the current one. However, this doesn't work. Also tried various update calls inbetween OnInitDialog and OnSetActive, but to no avail.
Any ideas what I'm doing wrong? The help would be very much appreciated
James
|
|
|
|
|
I remembered dealing with a quirky problem involving CTreeCtrl checkboxes. I checked some code in an old project, and found this:
<br />
<br />
m_treeCtrl.ModifyStyle(TVS_CHECKBOXES, 0);<br />
m_treeCtrl.ModifyStyle(0, TVS_CHECKBOXES);<br />
The fix came via the one of the newsgroups. I don't know if it will help your problem, but it's worth a shot.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Thankyou, thankyou, thankyou!!!!
As I expected, a random bug with a very random solution.
But it works
|
|
|
|
|
Please tell me that why does the first two bytes of a Bitmap image is being shown as '19778' which is equal to '4D42H' in VC environent.
whereas in theory it is to be 'BM' which is '424DH' in the bitmap image.
MoQuisha
|
|
|
|
|
Ascii Code of 'B' = 0x42
Ascii Code of 'M' = 0x4D
'BM' is the signature of the bitmap file, it helps the image viewers to identify that this file is a bitmap file. If you rename a text file and make its extension .bmp than it does not mean that it is a windows bitmap file.
http://www.priyank.in/
|
|
|
|
|
Hello,
It has something to do with the way data is stored in the memory of the computer. This problem is also known as the NUXI problem.
Read this[^] for more information about the problem.
I also got the blogging virus..[^]
|
|
|
|
|
|
Hello,
I have the following code:
<br />
#define A_THING(ARG) \<br />
# define ANOTHER_THING const ARG \<br />
When I compile the code, I get the following error: "error C2162: expected macro formal parameter"
The following code does not produce errors:
<br />
#define A_THING() \<br />
# define ANOTHER_THING const ARG<br />
The most weird part is, that I don't even use the first macro in the code. If I use it, I get the same errors...
I also got the blogging virus..[^]
|
|
|
|
|
|
|
Bob Stanneveld wrote:
I have the following code:
#define A_THING(ARG)
Then Where is the Problem Bob!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
|
I have found the source of my problem. This is that the '#' symbol is used inside macros to make a string of an argument. For example:
<br />
#define TO_STRING(arg) #arg<br />
<br />
TO_STRING(This is a string)
So the compiler looks for an argument named 'define', but cannot find it, thus issuing an error. Is there any way that I can work around this problem?
Thanks in advance
I also got the blogging virus..[^]
|
|
|
|
|
Don't do the line continuations. To the preprocessor, it sees:
#define A_THING(ARG) # define ANOTHER_THING const ARG \....
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I'm working on a program that I'd like to be open to customization by the user. It will generate messages (to be sent over Ethernet or serial ports) and allow the user to specify a set of rules to follow when doing so. I'd like the user to be able to create a list of steps to take and also allow the user to create loops and test conditions (if, else, ...).
For now, I'm hardcoding task types but it would be nice if I could allow the user to write a script that my software could understand and follow instead of forcing the user to use my pre-built task types.
I know it's not going to be easy or quick but I'd still like to look into it further. Does anyone know where I might find information on doing something like this? Would it be possible to use an existing scripting language (PERL or other)?
Thanks for any info you might have on this.
|
|
|
|
|
The older "Visual BASIC for Applications" possibly
Or try this msdn.microsoft.com/scripting
|
|
|
|
|
I want to take the color of any pixel on the screen.
I want to simulate mouse click at any position at the screen.
I don't have idea how to do this . and I'll appreciate any idea.
Thanks in advance.
|
|
|
|
|
isn't this help CDC::GetPixel(..)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi Community,
how can i use SetAccountInformation(L"",NULL); in C++ when i create a new Task with ITaskSchedule, when i create new WorkItem wit Username and Userpassword then the task is created ok, but if i want to create a Task without a Username and Password, with Systemaccount, the Task ist created but newer started, i can't start them manualy to? What is the problem?
here litle code:
<br />
if(m_sPassword == "")<br />
{<br />
hr = pITask->SetAccountInformation(L"",NULL);
}<br />
else<br />
{<br />
hr = pITask->SetAccountInformation(m_sUserName.AllocSysString(),m_sPassword.AllocSysString());<br />
}<br />
pITask->QueryInterface(IID_IPersistFile,(void **)&pIPersistFile);<br />
pIPersistFile->Save(NULL,TRUE);<br />
<br />
What ist the error here?
regards
mirsad
|
|
|
|
|
hey all,
i need to know how many sub-directories are under a certain direcotry (could be a hard disk)...
at the moment im using the following code and just wlaking the directory tree but its pretty slow.. can some1 help me out and speed it up (or better yet, tell me the win32 api call i dont know abnout which does this all for me )
<br />
int GetFileFolderCount(char* folder, int recurse, char *ignoreFolders, int *folders)<br />
{<br />
WIN32_FIND_DATA FindFileData;<br />
HANDLE hFind;<br />
int fileFound = 1;<br />
int len = strlen(folder)+5;<br />
char *searchPath = (char*)malloc(len);<br />
if (!searchPath) return 0;<br />
if (folder[strlen(folder)-1]=='\\')<br />
folder[strlen(folder)-1] = '\0';<br />
_snprintf(searchPath,len ,"%s\\*.*",folder);<br />
hFind = FindFirstFile(searchPath, &FindFileData);<br />
if (hFind == INVALID_HANDLE_VALUE) return 0;<br />
<br />
while (fileFound && continueSearch)<br />
{<br />
if (recurse && FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)<br />
{<br />
char *newSearch;<br />
if (!strcmp(FindFileData.cFileName,".") || !strcmp(FindFileData.cFileName,".."))<br />
{<br />
fileFound = FindNextFile(hFind,&FindFileData);<br />
continue;<br />
}<br />
len = strlen(folder)+strlen(FindFileData.cFileName)+5;<br />
newSearch = (char*)malloc(len);<br />
if (!newSearch) return 0;<br />
_snprintf(newSearch,len,"%s\\%s\0",folder,FindFileData.cFileName);<br />
if (!ignorefolder(newSearch,ignoreFolders))<br />
{<br />
(*folders)++;<br />
GetFileFolderCount(newSearch,recurse,ignoreFolders ,folders);<br />
}<br />
free(newSearch);<br />
}<br />
else if (!recurse && FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)<br />
{<br />
fileFound = FindNextFile(hFind,&FindFileData);<br />
continue; <br />
}<br />
fileFound = FindNextFile(hFind,&FindFileData);<br />
}<br />
FindClose(hFind);<br />
free(searchPath);<br />
return 1;<br />
}<br />
thanx
|
|
|
|
|
that is exactly how I would do it, I don't see anything you can do to speed it up. There is no win32 api to do directly what you want.
-- Rocky Dean Pulley
|
|
|
|
|
hello everybody,
i know, it's been few times i've asked this already, but as i didn't took notes and apply the answers, i cannot find them anymore ...
the only thing i remember is that Mr Alok did answer usefully my request (that was a function like FilePathExists() , but i can't find it. was it really that ?).
so, the question is :
i'd like to check (when i get a File path and name throw GetSaveFileName() - MFC) to check whether the file really exist or not.
As precision, i am working both on VC++ + and .NET 2003, and still MFC.
thanks in advance.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|