- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I am trying to write a subroutine to convert a variant to a string but I am not having any success. I would be grateful for any assistance.
The code I have come up with so far is:
subroutine
VariantToString(V, Str) use ifwinty use ifcom implicit none type(variant), intent(in):: V character(len=*), intent(out):: Str integer*4:: Hr select case (V%varVal%vt) case (VT_BSTR)Hr = ConvertBSTRtoString( V%varVal%bstrVal, Str )
if ( Hr .ne. S_OK ) thenStr = ""
end case default Str = "" end selectend
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I think you ought to define a length foryour character buffer. Try
CHARACTER(100) STR
and see if that works. I assume ConvertBSTRtoString is defined in one of the IVF modules you are USEing, along with S_OK and VT_BSTR etc. ? There should be a routine or function for determining the length of the bit-string buffer, so that you can test if your character string buffer is large enough to take the bit string. If not, you can do it using
INTEGER(4) strbufflen
POINTER (pString, strbufflen)
...
pString=V%varVal%bstrVal - 4
The bit-string pointer 'V%varVal%bstrVal' points to the first character in the bit string, butthe bit string itselfis preceded by 4-bytes that stores the length of the bit string buffer, so point 'pString' to the first of these 4 bytes, after which the bit-string lengthwillbe accessable as 'strbufflen'.
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite