Path: utzoo!attcan!uunet!aplcen!haven!umd5!brianf From: brianf@umd5.umd.edu (Brian Farmer) Newsgroups: comp.windows.ms Subject: Re: __ahincr Message-ID: <6908@umd5.umd.edu> Date: 18 Jul 90 14:35:20 GMT References: <6887@umd5.umd.edu> <118500044@uxa.cso.uiuc.edu> Reply-To: brianf@umd5.umd.edu (Brian Farmer) Organization: University of Maryland, College Park Lines: 72 In article <118500044@uxa.cso.uiuc.edu> mms00786@uxa.cso.uiuc.edu writes: >Under enhanced and standard mode, I am now allowed to GlobalAlloc chunks greater >than 64K. I assume I am also able to GlobalLock these large chunks. Question is, >how do I access this memory? For example, suppose I wanted to create a memory >chunk filled with letter 'a', would the following work? > > hMem = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, 70000); > lpStr = GlobalLock (hMem); > for (i=0; i < 70000; i++) > *lpStr++ = 'a'; > Only if lpStr is a huge pointer. >Or would I have to worry about segment boundaries etc, possibly through >the use of this mysterious _ahincr? Only if lpStr is just a long pointer. I wanted to know about is because we have a routine needs to be as quick as possible so was written in in-line assembly. Here is a routine that I wrote to test __ahincr that should do what you want. A huge pointer is easier for C. /* __ahincr needs to be define like: */ extern int _ahincr; void AhincrTest (HWND hWnd) { HANDLE foo; char far *foo2; int incr, *ptr; LONG i; incr = &_incr; foo = GlobalAlloc (GMEM_MOVEABLE, 70000); foo2 = (char far *)GlobalLock (foo); incr = &_ahincr; ptr = (int *)&foo2; while (i<70000) { foo2[(int)i] = 'a'; /* (int)i or LOWORD (i) should work here */ i++; if (!LOWORD (i)) ptr[1] += incr; /* update the segment pointer. you can also use __ahincr for subtraction to go backward in array. */ } GlobalUnlock (foo); MessageBox (hWnd, "finished looping", "Generic.C", MB_OK); } Thanks to Microsoft for posting there earlier responses, they really helped. Brian Farmer brianf@umd5.umd.edu