예제 #1
0
	bool empty()
	{
		if( m_ParentPath.size() )
		{
			char buf[2];
			size_t len = GetPrivateProfileStringA(m_ParentPath.c_str(), m_obj->m_name.c_str(), "", buf, sizeof(buf), m_pPath->c_str());
			return len == 0;
		}
		else if (m_obj && m_obj->m_name.size())
		{
			char buf[3];
			tstring app = m_obj->m_name;
			size_t len = GetPrivateProfileSectionA(app.c_str(), buf, sizeof(buf), m_pPath->c_str());
			return len == 0;
		}
		return true;
	}
예제 #2
0
파일: msvideo_main.c 프로젝트: dvdhoo/wine
static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
{
    CHAR buf[2048], fccTypeStr[5], *s;
    DWORD i, cnt = 0, lRet;
    BOOL result = FALSE;
    HKEY hKey;

    fourcc_to_string(fccTypeStr, fccType);
    fccTypeStr[4] = '.';

    /* first, go through the registry entries */
    lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &hKey);
    if (lRet == ERROR_SUCCESS) 
    {
        DWORD name, data, type;
        i = 0;
        for (;;)
	{
	    name = 10;
	    data = sizeof buf - name;
	    lRet = RegEnumValueA(hKey, i++, buf, &name, 0, &type, (LPBYTE)(buf+name), &data);
	    if (lRet == ERROR_NO_MORE_ITEMS) break;
	    if (lRet != ERROR_SUCCESS) continue;
	    if (name != 9 || strncasecmp(buf, fccTypeStr, 5)) continue;
	    buf[name] = '=';
	    if ((result = handler(buf, cnt++, param))) break;
	}
    	RegCloseKey( hKey );
    }
    if (result) return result;

    /* if that didn't work, go through the values in system.ini */
    if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini")) 
    {
	for (s = buf; *s; s += strlen(s) + 1)
	{
            TRACE("got %s\n", s);
	    if (strncasecmp(s, fccTypeStr, 5) || s[9] != '=') continue;
	    if ((result = handler(s, cnt++, param))) break;
	}
    }

    return result;
}
예제 #3
0
static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
{
    char fccTypeStr[4];
    char name_buf[10];
    char buf[2048];

    DWORD i, cnt = 0, lRet;
    BOOL result = FALSE;
    HKEY hKey;

    fourcc_to_string(fccTypeStr, fccType);

    /* first, go through the registry entries */
    lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &hKey);
    if (lRet == ERROR_SUCCESS) 
    {
        i = 0;
        for (;;)
        {
            DWORD name_len = 10, driver_len = 128;
            lRet = RegEnumValueA(hKey, i++, name_buf, &name_len, 0, 0, (BYTE *)buf, &driver_len);
            if (lRet == ERROR_NO_MORE_ITEMS) break;
            if (name_len != 9 || name_buf[4] != '.') continue;
            if (fccType && strncasecmp(name_buf, fccTypeStr, 4)) continue;
            if ((result = handler(name_buf, buf, cnt++, param))) break;
        }
        RegCloseKey( hKey );
    }
    if (result) return result;

    /* if that didn't work, go through the values in system.ini */
    if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini")) 
    {
        char *s;
        for (s = buf; *s; s += strlen(s) + 1)
        {
            if (s[4] != '.' || s[9] != '=') continue;
            if (fccType && strncasecmp(s, fccTypeStr, 4)) continue;
            if ((result = handler(s, s + 10, cnt++, param))) break;
        }
    }

    return result;
}
예제 #4
0
/***********************************************************************
 *           MSACM_RegisterAllDrivers()
 */
void MSACM_RegisterAllDrivers(void)
{
    LPSTR pszBuffer;
    DWORD dwBufferLength;

    /* FIXME
     *  What if the user edits system.ini while the program is running?
     *  Does Windows handle that?
     */
    if (MSACM_pFirstACMDriverID)
	return;

    /* FIXME: Does not work! How do I determine the section length? */
    dwBufferLength = 1024;
/* EPP 	GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */

    pszBuffer = (LPSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength);
    if (GetPrivateProfileSectionA("drivers32", pszBuffer, dwBufferLength, "system.ini")) {
	char* s = pszBuffer;
	while (*s) {
	    if (!strncasecmp("MSACM.", s, 6)) {
		char *s2 = s;
		while (*s2 != '\0' && *s2 != '=') s2++;
		if (*s2) {
		    *s2 = '\0';
		    MSACM_RegisterDriver(s, s2 + 1, 0);
		    *s2 = '=';
		}
	    }
	    s += strlen(s) + 1; /* Either next char or \0 */
	}
    }

    HeapFree(MSACM_hHeap, 0, pszBuffer);

    MSACM_RegisterDriver("msacm32.dll", "msacm32.dll", 0);
}
예제 #5
0
파일: file.c 프로젝트: bilboed/wine
/***********************************************************************
 *           GetPrivateProfileSection   (KERNEL.418)
 */
INT16 WINAPI GetPrivateProfileSection16( LPCSTR section, LPSTR buffer,
                                         UINT16 len, LPCSTR filename )
{
    return GetPrivateProfileSectionA( section, buffer, len, filename );
}
예제 #6
0
파일: file.c 프로젝트: bilboed/wine
/***********************************************************************
 *           GetPrivateProfileString   (KERNEL.128)
 */
INT16 WINAPI GetPrivateProfileString16( LPCSTR section, LPCSTR entry,
                                        LPCSTR def_val, LPSTR buffer,
                                        UINT16 len, LPCSTR filename )
{
    if (!section)
    {
        if (buffer && len) buffer[0] = 0;
        return 0;
    }
    if (!entry)
    {
        /* We have to return the list of keys in the section but without the values
         * so we need to massage the results of GetPrivateProfileSectionA.
         */
        UINT ret, oldlen = len, size = min( len, 1024 );
        LPSTR data, src;

        for (;;)
        {
            if (!(data = HeapAlloc(GetProcessHeap(), 0, size ))) return 0;
            ret = GetPrivateProfileSectionA( section, data, size, filename );
            if (!ret)
            {
                if (len) *buffer = 0;
                HeapFree( GetProcessHeap(), 0, data );
                return 0;
            }
            if (ret != size - 2) break;
            /* overflow, try again */
            size *= 2;
            HeapFree( GetProcessHeap(), 0, data );
        }

        src = data;
        while (len && *src)
        {
            char *p = strchr( src, '=' );

            if (!p) p = src + strlen(src);
            if (p - src < len)
            {
                memcpy( buffer, src, p - src );
                buffer += p - src;
                *buffer++ = 0;
                len -= (p - src) + 1;
                src += strlen(src) + 1;
            }
            else  /* overflow */
            {
                memcpy( buffer, src, len );
                buffer += len;
                len = 0;
            }
        }
        HeapFree( GetProcessHeap(), 0, data );

        if (len)
        {
            *buffer = 0;
            return oldlen - len;
        }
        if (oldlen > 2)
        {
            buffer[-2] = 0;
            buffer[-1] = 0;
            return oldlen - 2;
        }
        return 0;
    }
    return GetPrivateProfileStringA( section, entry, def_val, buffer, len, filename );
}
예제 #7
0
static void test_profile_sections(void)
{
    HANDLE h;
    int ret;
    DWORD count;
    char buf[100];
    char *p;
    static const char content[]="[section1]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n[section2]\r\n";
    static const char testfile4[]=".\\testwine4.ini";
    BOOL on_win98 = FALSE;

    DeleteFileA( testfile4 );
    h = CreateFileA( testfile4, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", testfile4);
    if( h == INVALID_HANDLE_VALUE) return;
    WriteFile( h, content, sizeof(content), &count, NULL);
    CloseHandle( h);

    /* Some parameter checking */
    SetLastError(0xdeadbeef);
    ret = GetPrivateProfileSectionA( NULL, NULL, 0, NULL );
    ok( ret == 0, "expected return size 0, got %d\n", ret );
    ok( GetLastError() == ERROR_INVALID_PARAMETER ||
        GetLastError() == 0xdeadbeef /* Win98 */,
        "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
    if (GetLastError() == 0xdeadbeef) on_win98 = TRUE;

    SetLastError(0xdeadbeef);
    ret = GetPrivateProfileSectionA( NULL, NULL, 0, testfile4 );
    ok( ret == 0, "expected return size 0, got %d\n", ret );
    ok( GetLastError() == ERROR_INVALID_PARAMETER ||
        GetLastError() == 0xdeadbeef /* Win98 */,
        "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());

    if (!on_win98)
    {
        SetLastError(0xdeadbeef);
        ret = GetPrivateProfileSectionA( "section1", NULL, 0, testfile4 );
        ok( ret == 0, "expected return size 0, got %d\n", ret );
        ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
    }

    SetLastError(0xdeadbeef);
    ret = GetPrivateProfileSectionA( NULL, buf, sizeof(buf), testfile4 );
    ok( ret == 0, "expected return size 0, got %d\n", ret );
    ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());

    SetLastError(0xdeadbeef);
    ret = GetPrivateProfileSectionA( "section1", buf, sizeof(buf), NULL );
    ok( ret == 0, "expected return size 0, got %d\n", ret );
    todo_wine
    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());

    /* And a real one */
    ret=GetPrivateProfileSectionA("section1", buf, sizeof(buf), testfile4);
    for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1)
        p[-1] = ',';
    ok( ret == 35 && !strcmp( buf, "name1=val1,name2=,name3,name4=val4"), "wrong section returned(%d): %s\n",
            ret, buf);
    ok( buf[ret-1] == 0 && buf[ret] == 0, "returned buffer not terminated with double-null\n" );
    ok( GetLastError() == S_OK, "expected S_OK, got %d\n", GetLastError());

    DeleteFileA( testfile4 );
}
예제 #8
0
파일: rps.cpp 프로젝트: kxepal/miranda-ng
BOOL GetSettings(const char *section, char *buffer, size_t bufferSize)
{
	buffer[0] = '\0\0';
	return (BOOL)GetPrivateProfileSectionA(section, buffer, (DWORD)bufferSize, gIniFile) != 0;
}