Click here to Skip to main content
15,884,298 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Export a 'long' from unmanaged code into .net Pin
Kate-X25726-Apr-23 21:19
Kate-X25726-Apr-23 21:19 
GeneralRe: Export a 'long' from unmanaged code into .net Pin
OriginalGriff26-Apr-23 21:20
mveOriginalGriff26-Apr-23 21:20 
GeneralRe: Export a 'long' from unmanaged code into .net Pin
englebart27-Apr-23 14:07
professionalenglebart27-Apr-23 14:07 
GeneralRe: Export a 'long' from unmanaged code into .net Pin
OriginalGriff27-Apr-23 18:59
mveOriginalGriff27-Apr-23 18:59 
GeneralRe: Export a 'long' from unmanaged code into .net Pin
englebart28-Apr-23 6:17
professionalenglebart28-Apr-23 6:17 
GeneralRe: Export a 'long' from unmanaged code into .net Pin
Kate-X25714-May-23 22:32
Kate-X25714-May-23 22:32 
AnswerRe: Export a 'long' from unmanaged code into .net Pin
Shao Voon Wong26-Apr-23 15:57
mvaShao Voon Wong26-Apr-23 15:57 
AnswerRe: Export a 'long' from unmanaged code into .net Pin
GerhardKreuzer12-May-23 23:13
GerhardKreuzer12-May-23 23:13 
Hi,
lastly I found a working solution and its far from zipping data, thanks for that really good idea, but it was not April 1st, (and gives insight into your mindset).

The embedded framework didn't support passing 64 bit values between managed and unmanaged code. A little workaround is needed.
Fist create a new IntPnt object and pass this object to unmanged code by reference as parameter of some function. In unmanaged code use this pointer as any other pointer in C/C++, and assign the data you need.
Return from this unmanaged function and use the 'Marshal' class to readout the value.
Use a 'try finally' block to clean up memory in any case.

Managed code:
VB
Private Shared Function ReadFilePointer() As Long
        Dim ptr As IntPtr = Marshal.AllocHGlobal(Len(New Long()))
        Try
            GetBookmark(ptr)
            Return Marshal.ReadInt64(ptr)
        Finally
            Marshal.FreeHGlobal(ptr)
        End Try
    End Function


Unmanaged code:
C++
extern "C" { __declspec(dllexport) void		GetBookmark						(intptr_t*);					}

C++
void GetBookmark(intptr_t*  bmark)
{
	*bmark = ftell(outFile);
}



Hope this can help someone someday.

With best regards

Gerhard
GeneralSomething else interviewers do wrong Pin
jschell26-Apr-23 6:35
jschell26-Apr-23 6:35 
GeneralRe: Something else interviewers do wrong Pin
Richard MacCutchan26-Apr-23 21:21
mveRichard MacCutchan26-Apr-23 21:21 
GeneralRe: Something else interviewers do wrong Pin
Sander Rossel26-Apr-23 23:03
professionalSander Rossel26-Apr-23 23:03 
GeneralRe: Something else interviewers do wrong Pin
jschell27-Apr-23 5:03
jschell27-Apr-23 5:03 
GeneralRe: Something else interviewers do wrong Pin
charlieg28-Apr-23 2:01
charlieg28-Apr-23 2:01 
GeneralRe: Something else interviewers do wrong Pin
Paul Kemner27-Apr-23 3:39
Paul Kemner27-Apr-23 3:39 
GeneralRe: Something else interviewers do wrong Pin
charlieg28-Apr-23 2:02
charlieg28-Apr-23 2:02 
PraiseDeeply satisfying Pin
honey the codewitch26-Apr-23 3:54
mvahoney the codewitch26-Apr-23 3:54 
GeneralNew Windows 11 clean install issue PinPopular
Cp-Coder26-Apr-23 3:20
Cp-Coder26-Apr-23 3:20 
GeneralRe: New Windows 11 clean install issue Pin
obermd26-Apr-23 3:49
obermd26-Apr-23 3:49 
GeneralRe: New Windows 11 clean install issue Pin
Cp-Coder26-Apr-23 5:30
Cp-Coder26-Apr-23 5:30 
GeneralRe: New Windows 11 clean install issue Pin
obermd26-Apr-23 9:32
obermd26-Apr-23 9:32 
GeneralRe: New Windows 11 clean install issue Pin
dandy7227-Apr-23 3:48
dandy7227-Apr-23 3:48 
GeneralRe: New Windows 11 clean install issue Pin
jweled27-Apr-23 2:34
jweled27-Apr-23 2:34 
GeneralRe: New Windows 11 clean install issue Pin
Anthony King 202327-Apr-23 12:46
Anthony King 202327-Apr-23 12:46 
GeneralRe: New Windows 11 clean install issue Pin
Cp-Coder27-Apr-23 15:18
Cp-Coder27-Apr-23 15:18 
GeneralRe: New Windows 11 clean install issue Pin
Greg Lovekamp30-Apr-23 6:39
professionalGreg Lovekamp30-Apr-23 6:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.