I'm not a good C programmer but here is what I done:
declare palette variable:
GP_PALETTEENTRY arda_Pal[256] = {
0x1, 0xFFFF, 0xDF7F, 0xBEFB.... <fill your palette entries here>}
after you create gpsurface and set it,
GP_HPALETTE h_pal, old_pal;
h_pal = GpPaletteCreate(256...