registry and bad pointer problem

hi I have a function which returns me a variable then I use that variable to write to the registry..it just keeps giving me an Access violation reading location

following is snippets of code....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
int CXLCS_SIG_PROTOCOL::get_integer_value(int nKeyIndex)

{

    if(nKeyIndex < 0 || nKeyIndex > XLCSP_KEYWORD_TOTAL_NUM-1)return 0;

    char* pszKwordSeg = strstr(m_pszCurLine,_pgszKeyword[nKeyIndex]); //locate the keyword segment

    if(pszKwordSeg == NULL) return 0; //not found such keyword.

 //found the keyword,retrieve the value.

    int nSize = strlen(_pgszKeyword[nKeyIndex]);

    pszKwordSeg += nSize; //skip the keyword.

    //search '; ' delimitor...

    char bBackup=0;

    char* pKeyDelimitor = strstr(pszKwordSeg,_gszKeywordDelimitor);

    if(pKeyDelimitor != NULL) //otherwise, we may get the end of the pack?

        {

        bBackup = *pKeyDelimitor;

        *pKeyDelimitor = 0; //temperaily set a terminator ...

        }

    //retrieve the value...

 int nValue = atoi(pszKwordSeg); 

    if(pKeyDelimitor != NULL) *pKeyDelimitor = bBackup; //restore

    return nValue;

}


above is the function that returns a value which i want to write to the registry.

1
2
3
4
5
6
7
8
9
10
11
HKEY configKey;

		DWORD dwType;

		DWORD dwSize=200;

		if(RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\ConfApp\\", 0, KEY_ALL_ACCESS, &configKey)==ERROR_SUCCESS)

		{

			RegSetValueEx(configKey,"ConfRoom",NULL,REG_SZ,(BYTE *)protocol.get_integer_value(18),dwSize);

then i will do something like that to write to the directory...does anyone has any idea on how I can get passed this error?

(BYTE *)protocol.get_integer_value(18)
???
You're converting an integer to a pointer? There's no way that's ever going to work. You'd have to first convert the integer value to a string and then pass a pointer to that string.
yay it passed the exception...now my conversions has a bit of a problem...let me try to fix that...thanks for your help...first job doing c++ and I am suffering in it...lol
Topic archived. No new replies allowed.