Code:
,,,,,,,,,,,,,,,,,,,,,
static PTSTR ptext;
HGLOBAL hglobal // global handle for clipbord
PTSTR pglobat;
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
openclipboard(hwnd);
pglobal = globallock(hglobal);
if(ptext)
{
free(ptext);
ptext = NULL;
}
ptext = malloc(globalsize(hglobal));
strcpy(ptext, pglobal);
OR
Code:
char * pVarBeg, * pVarEnd, * pVarName, *pVarBlock ;
pVarBlock =GetEnvironmentStrings() ; // Get pointer to env block
while (*pVarBlock)
{
if(*pVarBlock != '='){
pVarBeg = pVarBlock ; // Beginning of variable name
while (*pVarBlock++ != '=') // Scan until '='
pVarEnd = pVarBlock - 1 ; // Points to '=' sign
iLength = pVarEnd - pVarBeg ; // Length of variable name
// Allocate memory for the variable name and terminating
// zero. Copy the variable name and append a zero.
pVarName = calloc (iLength + 1, sizeof (CHAR)) ;
CopyMemory (pVarName, pVarBeg, iLength * sizeof(char)) ;
pVarName[iLength] = '\0' ;
// Put the variable name in the list box and free memory.
SendMessage (hwndList, LB_ADDSTRING, 0, (LPARAM) pVarName) ;
free (pVarName) ;
}
while (*pVarBlock++ != '\0'); // Scan until terminating zero
}
FreeEnvironmentStrings (pVarBlock) ;