[Haskell-cafe] Haskell DLL crashes Excel
Kyra
kyra at veernet.ru
Fri Sep 22 06:57:52 EDT 2006
Andreas Marth wrote:
> type BSTR8 = Ptr Word8
>
> createBSTR8 :: String -> IO BSTR8
> createBSTR8 s = do
> let
> len :: Word32 = fromIntegral (length s)
> low_l :: Word8 = fromIntegral (len .&. 0xFFFF)
> low_h :: Word8 = fromIntegral (shiftR len 8 .&. 0xFFFF)
> high_l :: Word8 = fromIntegral (shiftR len 16 .&. 0xFFFF)
> high_h :: Word8 = fromIntegral (shiftR len 24 .&. 0xFFFF)
> arr <- newArray ([low_l,low_h,high_l,high_h] ++ map (fromIntegral .
> fromEnum) s ++ [0])
> return $! plusPtr arr 4
Use SysAllocString... family. Also, remember they (by convention) have
to be released from the client side.
Cheers,
Kyra
More information about the Haskell-Cafe
mailing list