?
Solved

Accessing Memory Address - No solution in over 2 months....

Posted on 2003-02-24
24
Medium Priority
?
287 Views
Last Modified: 2012-06-27
I only have 75 points to give, and I'm giving them all on this one...

I need someone who REALLY understands accessing memory by address (i.e. Copymem).

Here's the background:
I have converted some C++ code to VB.
I am using a company's DLL to integrate with their app.
When I query their app, it sends back an lParam which I then stuff into a Type (using Copymem).
The Type contains 3 vars, the last of which is an address.
I then use Copymem (again) to try to locate the next 'chunk' of data and shove it into another Type.

At this point, it always fails. Either a crash, or totally bogus values. I'm not sure if the Type def is the problem (thereby receiving a 'bad address') or if VB handles the address incorrectly.

You can download my project as a place to start. Note that you cannot run it from the IDE - you have to compile it or VB generates DLL errors (you can use 'resume next' in a few places and get past this, but I'm using a Callback, so VB still locks up...)

To download my sample VB6 project click here:
http://home.attbi.com/~whoit/Myrtest.zip

To download a trial version of the app I'm integrating with (You HAVE to do this, or you can't test anything):
http://www.infograph.com/forms/download/Step1.asp?product=myriad
After downloading and installing Myriad v6, look in the "intgclt\myrtest" folder. They have a compiled C app which does what I want:mitest32.exe
With this sample, you can 'connect to myriad' and issue the 'inquire document' command.
You can actually run this simultaneously with mine, and when I get the callback, so does mitest32.
They also have a bunch of sample C code and a basic API document "intgdoc.rtf".

Feel free to email me directly (whoit@attbi.com)

Is anyone bold enough to tackle this for a whopping 75 points? ;)

0
Comment
Question by:wehoit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 9
  • 2
24 Comments
 
LVL 1

Author Comment

by:wehoit
ID: 8030978
Anyone?
0
 
LVL 7

Expert Comment

by:webJose
ID: 8031716
Ok, I haven't downloaded anything, but it can't be that hard.

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSrc As Any, ByVal ByteLen As Long)

public type MyType
    myVar1 as boolean
    myVar2 as Integer
    myVar3 as long
end type

public type MyType2
    ....
end type

Public Sub MyCallBackFunc(byval lAddress as long)

dim data1 as MyType
dim data2 as MyType2

    copymemory data1, byval laddress, lenb(data1)
    copymemory data2, byval data1.myvar3, lenb(data2)
end sub
0
 
LVL 1

Author Comment

by:wehoit
ID: 8033681
Thanks for replying, but you really need to read my question more thoroughly.

I am way past everything your wrote.
The problem is much deeper than that.

If you would like to try to help, please at least download everything and see the problem for yourself.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:wehoit
ID: 8035886
I'm going to increase the point value on this question frequently until I get a solution.
0
 
LVL 7

Expert Comment

by:webJose
ID: 8036046
Well, to be honest, your explanation seems very clear:

"When I query their app, it sends back an lParam which I then stuff into a Type (using Copymem)."

Meaning:

You receive a struct address in a long variable.  You use CopyMemory to get the struct values.

"The Type contains 3 vars, the last of which is an address.
I then use Copymem (again) to try to locate the next 'chunk' of data and shove it into another Type."

Meaning:

One of the values obtained earlier is an address itself (pointer), so you use CopyMemory again to obtain the data.


What I wrote does exactly what you are explaining.  If it fails, it may be because of the data types.  Post the type definitions as you may be having a memory padding problem, or you may not be taking into account special datatypes like arrays, strings, or COM pointers.
0
 
LVL 1

Author Comment

by:wehoit
ID: 8036109
You should download the test project I gave a link for.
It has all the definitions, plus a composite of the C++ sample code defs that I started with.

You won't be able to run it without the additional download, also posted earlier.

I have tried several versions of declaring my Types, CopyMem etc.

The solution will not be as simple as posting the generic use of how to delcare a Type and CopyMem.

I've been working with this problem for over 2 months, trying a variety of delcarations, etc to no avail.

Before you say "it can't be that hard" I suggest you try the actual problem.

Please don't respond with generic information.
0
 
LVL 7

Expert Comment

by:webJose
ID: 8036194
wehoit, I won't download.

If you want my help, please comply to my requests and show the information I ask for.
0
 
LVL 1

Author Comment

by:wehoit
ID: 8036302
Okay - You asked for it -

/* THIS IS A COMPOSITE OF SEVERAL .H AND .C FILES TO SHOW THE MAIN
    CODE I'M INTERESTED IN....
   
#ifndef IGENUM    
#  ifdef __WIN32
    typedef int IGENUM;
#  else
    typedef long IGENUM;
#  endif
#endif

#ifndef IGINT
#  ifdef __WIN32
    typedef int IGINT;
#  else
    typedef long IGINT;
#  endif
#endif

#ifndef IGBOOL
  #ifdef __WIN32
    typedef int IGBOOL;
  #else
    typedef long IGBOOL;
  #endif
#endif

#define MAX_STRING                                         (256)
#define IGC_NOTIFY_CALLBACK_MESSAGE     (WM_USER+10000

/* I HAVE REMOVED MOST OF THE CONTENT OF THE ENUMS TO MAKE THIS EASIER TO READ THROUGH.....
           
/* This enumerated type is used to identify the execution command */
typedef enum {INTG_EXECUTE_NOTIFY_RETURN,
              INTG_EXECUTE_INQUIRE_DOCUMENT,
              INTG_EXECUTE_INQUIRE_SYSTEM,
             }ExecutionCommandType;

/* These are the notification message types which identify the type of  */
/* data packet being received by the integrating application            */
typedef enum {INTG_NOTIFY_NONE,
              INTG_NOTIFY_DOCUMENT_INFO,
             }NotifyMessageType;

/* This structure is used to retrieve the data passed from Myriad in the form of a notification message */
struct NotifyCallbackRecord{
  IGBOOL               Message;             /* The message ID for the notification                    */
  IGBOOL               DataStatus;          /* The status of the data attached to the notification    */
  char                 Data;                /* The address of the data attached to the notification   */
};

typedef enum {
      MONOCHROME_RASTER,
      COLOR_RASTER,
      VECTOR,
      TEXT
} ImageTypesEnum;

typedef struct {
  IGENUM Type;
} ImageType;

typedef enum {
    DEGREES_0,
    DEGREES_90,
    DEGREES_180,
    DEGREES_270
} OrientTypesEnum;

typedef struct {
      IGENUM Type;
} OrientType;

typedef enum {
  WINDOW_MINIMIZED,
  WINDOW_MAXIMIZED,
  WINDOW_WINDOWED
} WindowStateEnum;

typedef struct {
      IGENUM State;
} WindowState;

typedef struct {
      double WorldScale;
      char   Filename[MAX_PATH_FILENAME];
} ImageInfo, *pImageInfo;

typedef struct NotifyInquireDocument{
      double      Clip[4];                               /* current viewed area */
      double      Limits[4];                             /* limits of the document */
      char        MarkupFile[MAX_PATH_FILENAME];         /* The editable markup file if one opened, NULL if no markup opened */
  IGBOOL      MarkupChanged;                         /* If the current editable markup has been changed */
      char        Description[INQUIRE_DESCRIPTION_SIZE]; /* extracted from the folder file */      
      IGINT       DocWindowSize[4];                      /* The RECT associated with the image window */
      IGINT       DocWindowPosition[4];                  /* The device location of the window image (RECT) */
  WindowState DocWindowState;                        /* The state of the image window */
      IGINT       MyrWindowSize[4];                      /* The RECT associated with Myriad's main window */
      IGINT       MyrWindowPosition[4];                  /* The device location of Myriad's main window */
  WindowState MyrWindowState;                        /* The state of Myriad's main window */
      IGINT       NumberOfPages;                         /* The number of pages in the image */
      IGINT       ActivePage;                            /* Currently displayed page */
      ImageType   ImageType;                             /* Monochrome Raster, Color Raster, Vector, Text */
      OrientType  Orientation;                           /* Orientation (rotation)*/
      IGINT       Resolution;                            /* DPI */
      IGINT       Reserved;                              /* Four byte field for correct compiler structure padding in 16 and 32 bit environments */
      IGINT       NumberOfFiles;                         /* Number of entries in the filepath array of files */
      ImageInfo   ImageInfo[1];                          /* For all images (first entry and subsequent overlays): full path and worldscale */
} NotifyInquireDocument, *pNotifyInquireDocument;


/* THIS IS THE INITIAL COMMAND ISSUED TO START THE CALLBACK.....
void doInquireDocument(BOOL bUseCommandString)
{
       char ExecutionString[MAX_STRING];

   if(!IsServerUp()){
      PrintLine("There is no connection to Myriad.");
      return;
   }

   if(bUseCommandString){
      PrintLine("Sending Inquire Document string to Myriad...");

      // Setup the execution string
     strcpy(ExecutionString, "inquire_document()");

     if(ProcessExecutionString(ExecutionString)){
         PrintLine("--> Inquire Document succeeded.");
     }else{
         PrintLine("--> Inquire Document failed.");
     }
  }else{
     PrintLine("Sending Inquire Document to Myriad...");

     if(ProcessExecutionCommand(INTG_EXECUTE_INQUIRE_DOCUMENT, NULL)){
        PrintLine("--> Inquire Document succeeded.");
     }else{
        PrintLine("--> Inquire Document failed.");
     }
  }
}


long FAR PASCAL WndProc(HWND hWnd, unsigned iMessage, WORD wParam, LONG lParam)
{
   int ret=0;
   int rc=TRUE;

   switch (iMessage){
      case WM_PAINT:{
         PaintWindow();
     }
     break;

      case IGC_NOTIFY_CALLBACK_MESSAGE:{
        NotifyCallbackHandler((struct NotifyCallbackRecord *)lParam);
     }
     break;

      case WM_COMMAND:{
         switch (wParam){
          case IDM_COMMAND_COMMAND_INQUIRE_DOCUMENT:{
                 doInquireDocument(FALSE);
            }
             break;
        default:{
         return DefWindowProc(hWnd, iMessage, wParam, lParam);
      }
   }

   return(FALSE);
}

// Callback handler for notification messages
void NotifyCallbackHandler(struct NotifyCallbackRecord *pCallbackRecord)
{
   char tempstring[MAX_STRING];
   
   switch(pCallbackRecord->Message){
         case INTG_NOTIFY_DOCUMENT_INFO: {
         HandleInquireDocumentPrint(&pCallbackRecord->Data);
      }
      break;
      default:{
         sprintf(tempstring, ">>> Received unhandled notify message %d", (int)pCallbackRecord->Message);
         PrintLine(tempstring);
      }
      break;
   }
}

void HandleInquireDocumentPrint(void *pData)
{
   pNotifyInquireDocument pRecord;
   char                   tempString[MAX_STRING];
   pImageInfo             ptr;
   int                    i;


   if ((pRecord = pData) != NULL) {
      sprintf(tempString, ">>> Inquire Document Info: ");
      PrintLine(tempString);

      if (pRecord->MarkupFile[0] != '\0') {
         sprintf(tempString, "Markup file: %s", pRecord->MarkupFile);
         PrintLine(tempString);
         if (pRecord->MarkupChanged)
            sprintf(tempString, "Markup file has been changed");
         else
            sprintf(tempString, "Markup file has not been changed");
         PrintLine(tempString);
      }
      else {
         sprintf(tempString, "Markup file: None");
         PrintLine(tempString);
      }

      sprintf(tempString, "Description: %s", pRecord->Description);
      PrintLine(tempString);

      sprintf(tempString, "Current viewed area (clip): %lf, %lf, %lf, %lf", pRecord->Clip[0],
                           pRecord->Clip[1], pRecord->Clip[2], pRecord->Clip[3]);
      PrintLine(tempString);

      sprintf(tempString, "Limits of the document: %lf, %lf, %lf, %lf", pRecord->Limits[0],
                           pRecord->Limits[1], pRecord->Limits[2], pRecord->Limits[3]);
      PrintLine(tempString);

      sprintf(tempString, "Document window size: %ld, %ld, %ld, %ld", pRecord->DocWindowSize[0],
         pRecord->DocWindowSize[1], pRecord->DocWindowSize[2], pRecord->DocWindowSize[3]);
      PrintLine(tempString);

      sprintf(tempString, "Document window position: %ld, %ld, %ld, %ld", pRecord->DocWindowPosition[0],
         pRecord->DocWindowPosition[1], pRecord->DocWindowPosition[2], pRecord->DocWindowPosition[3]);
      PrintLine(tempString);

     strcpy(tempString, "Document window state: ");

     switch(pRecord->DocWindowState.State){
        case WINDOW_MINIMIZED : strcat(tempString, "Minimized");break;
        case WINDOW_MAXIMIZED : strcat(tempString, "Maximized");break;
        case WINDOW_WINDOWED  : strcat(tempString, "Windowed");break;
     }

     PrintLine(tempString);

      sprintf(tempString, "Myriad window size: %ld, %ld, %ld, %ld", pRecord->MyrWindowSize[0],
         pRecord->MyrWindowSize[1], pRecord->MyrWindowSize[2], pRecord->MyrWindowSize[3]);
      PrintLine(tempString);

      sprintf(tempString, "Myriad window position: %ld, %ld, %ld, %ld", pRecord->MyrWindowPosition[0],
         pRecord->MyrWindowPosition[1], pRecord->MyrWindowPosition[2], pRecord->MyrWindowPosition[3]);
      PrintLine(tempString);

     strcpy(tempString, "Myriad window state: ");

     switch(pRecord->MyrWindowState.State){
        case WINDOW_MINIMIZED : strcat(tempString, "Minimized");break;
        case WINDOW_MAXIMIZED : strcat(tempString, "Maximized");break;
        case WINDOW_WINDOWED  : strcat(tempString, "Windowed");break;
     }

     PrintLine(tempString);

      sprintf(tempString, "Number of pages: %ld", pRecord->NumberOfPages);
      PrintLine(tempString);

      sprintf(tempString, "Active page: %ld", pRecord->ActivePage);
      PrintLine(tempString);

      sprintf(tempString, "Image type: ");
      switch (pRecord->ImageType.Type) {
         case MONOCHROME_RASTER: strcat(tempString, "Monochrome Raster"); break;
         case COLOR_RASTER: strcat(tempString, "Color Raster"); break;
      case VECTOR: strcat(tempString, "Vector"); break;
         case TEXT: strcat(tempString, "Text"); break;
      }
      PrintLine(tempString);

      sprintf(tempString, "Orientation: ");
      switch (pRecord->Orientation.Type) {
      case DEGREES_0: strcat(tempString, "0 Degrees"); break;
         case DEGREES_90: strcat(tempString, "90 Degrees"); break;
      case DEGREES_180: strcat(tempString, "180 Degrees"); break;
         case DEGREES_270: strcat(tempString, "270 Degrees"); break;
      }
      PrintLine(tempString);

      sprintf(tempString, "Resolution: %ld", pRecord->Resolution);
      PrintLine(tempString);

      sprintf(tempString, "Number of files: %ld", pRecord->NumberOfFiles);
      PrintLine(tempString);

      sprintf(tempString, "Files:");
      PrintLine(tempString);

      ptr = pRecord->ImageInfo;
   
      for (i = 0; i < pRecord->NumberOfFiles; i++) {
         sprintf(tempString, "Name:%s  World Scale:%lf", ptr->Filename, ptr->WorldScale);
         PrintLine(tempString);
         ptr++;
      }
         
   } else {
      PrintLine(">>> Notify Inquire Document (Invalid data packet)");
   }
}



Now, Here's my VB vesrsion:
Public Declare Function StartAndInitServer Lib ".\myrcmd32.dll" (ByVal ServerName As String) As Boolean
Public Declare Function IsServerUp Lib "myrcmd32.dll" () As Boolean
Public Declare Function ProcessExecutionString Lib "myrcmd32.dll" (ByVal pString As String) As Boolean
Public Declare Function SetNotifyWindow Lib "myrcmd32.dll" (ByVal hWnd As Long) As Boolean

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Three versions for testing
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Long, ByVal cbCopy As Long)
Private Declare Sub CopyMemory3 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Double, ByVal cbCopy As Long)

Public Const MYRIAD_EXECUTABLE_NAME As String = "myriad32.exe"
Private Const GWL_WNDPROC = (-4)
Private Const WM_USER As Long = &H400
Private Const IGC_NOTIFY_CALLBACK_MESSAGE  As Long = (WM_USER + 10000)

Private Enum isostrings
    EXECUTE_ISO_FONT
    EXECUTE_ISO_CLEAR_ALL
    EXECUTE_ISO_RESTORE_DEFAULTS
    EXECUTE_ISO_TOPLEFT
    EXECUTE_ISO_TOPCENTER
    EXECUTE_ISO_TOPRIGHT
    EXECUTE_ISO_BOTTOMLEFT
    EXECUTE_ISO_BOTTOMCENTER
    EXECUTE_ISO_BOTTOMRIGHT
    EXECUTE_ISO_LEFTTOP
    EXECUTE_ISO_LEFTCENTER
    EXECUTE_ISO_LEFTBOTTOM
    EXECUTE_ISO_RIGHTTOP
    EXECUTE_ISO_RIGHTCENTER
    EXECUTE_ISO_RIGHTBOTTOM
    EXECUTE_ISO_WATERMARK
End Enum

Private Enum DataStatusType
    INTG_STATUS_COMPLETE_DATA
    INTG_STATUS_PARTIAL_DATA
    INTG_STATUS_NO_DATA
    INTG_STATUS_REPLY_REQUESTED
End Enum

Private Enum ExecutePrintScaleTypes
    EXECUTE_PRINT_SCALE_PAGE
    EXECUTE_PRINT_SCALE_TO_SCALE
End Enum

Private Enum ExecutePrintRangeTypes
    EXECUTE_PRINT_RANGE_ALL
    EXECUTE_PRINT_RANGE_PAGES
    EXECUTE_PRINT_RANGE_CURRENT
End Enum

Private Enum ExecutePrintOrientTypes
    EXECUTE_PRINT_ORIENT_PORTRAIT
    EXECUTE_PRINT_ORIENT_LANDSCAPE
End Enum

Private Enum ExecutePrintPrintWhatTypes
    EXECUTE_PRINT_DOCUMENT
    EXECUTE_PRINT_NOTES
End Enum

' These are the notification message types which identify the type of
' data packet being received by the integrating application
Private Enum NotifyMessageType
    INTG_NOTIFY_NONE
    INTG_NOTIFY_EXECUTION_RETURN
    INTG_NOTIFY_MOUSEMOVE
    INTG_NOTIFY_LBUTTONDOWN
    INTG_NOTIFY_LBUTTONUP
    INTG_NOTIFY_LBUTTONDBLCLICK
    INTG_NOTIFY_EXIT
    INTG_LOAD_FILEBEGIN
    INTG_LOAD_BLOCKBEGIN
    INTG_LOAD_ATTRIBUTE
    INTG_LOAD_BLOCKEND
    INTG_LOAD_FILEEND
    INTG_DISPLAY_FILEBEGIN
    INTG_DISPLAY_BLOCKBEGIN
    INTG_DISPLAY_ATTRIBUTE
    INTG_DISPLAY_BLOCKEND
    INTG_DISPLAY_FILEEND
    INTG_LAUNCH_ATTRIBBLOCK
    INTG_NOTIFY_SET_RETURN_DATA
    INTG_NOTIFY_FILE_LOADED
    INTG_NOTIFY_VIEWPORT_CLOSE
    INTG_NOTIFY_OPEN_MARKUP
    INTG_NOTIFY_SAVE_MARKUP
    INTG_NOTIFY_MARKUP_SAVED
    INTG_NOTIFY_CLOSE_MARKUP
    INTG_NOTIFY_IMAGE_CHANGE
    INTG_NOTIFY_GET_LAYER_INFO
    INTG_NOTIFY_GET_ISO_STRING
    INTG_NOTIFY_DATABASE_LOOKUP
    INTG_NOTIFY_PRINT
    INTG_NOTIFY_PRINT_COMPLETE
    INTG_NOTIFY_UD_MENU
    INTG_NOTIFY_OPEN_MARKUP_REQUEST
    INTG_NOTIFY_DOCUMENT_INFO
    INTG_NOTIFY_SYSTEM_INFO
    INTG_NOTIFY_SAVEAS_MARKUP_REQUEST
    INTG_NOTIFY_GET_AUTHORS
    INTG_NOTIFY_CHANGEMARK_VIEWED
    INTG_NOTIFY_GET_CHANGEMARKS
    INTG_NOTIFY_NEW_MARKUP
    INTG_NOTIFY_RUN_SILENT_MSG
    INTG_NOTIFY_ISO_DISPLAY
    INTG_NOTIFY_ISO_EDIT
    INTG_NOTIFY_DATABASE_ISO_LOOKUP
    INTG_NOTIFY_INTEGRATION_ENABLED
    INTG_NOTIFY_3D_MODEL_LOADED
    INTG_NOTIFY_3D_COMPONENT_SELECTION_CHANGED
    INTG_NOTIFY_3D_COMPONENT_LIST_ENABLED
    INTG_NOTIFY_PRINT_PREVIEW_COMPLETE
    INTG_NOTIFY_OPEN_MVS_REQUEST
    INTG_NOTIFY_SAVEAS_MVS_REQUEST
    INTG_NOTIFY_MVS_SAVED
    INTG_NOTIFY_CLOSE_MVS
    INTG_NOTIFY_HTML_EXPORT_FILE_WRITTEN
    INTG_NOTIFY_MVS_VIEW_CREATED
    INTG_NOTIFY_VIEW_SET_FILE_LOADED
    INTG_NOTIFY_VIEW_SET_NEEDS_SAVING
End Enum

Private Enum ExecutePrintPaperSizeTypes
    EXECUTE_PRINT_SIZE_DEFAULT
    EXECUTE_PRINT_SIZE_LETTER
    EXECUTE_PRINT_SIZE_LEGAL
    EXECUTE_PRINT_SIZE_A4
    EXECUTE_PRINT_SIZE_CSHEET
    EXECUTE_PRINT_SIZE_DSHEET
    EXECUTE_PRINT_SIZE_ESHEET
    EXECUTE_PRINT_SIZE_LETTERSMALL
    EXECUTE_PRINT_SIZE_TABLOID
    EXECUTE_PRINT_SIZE_LEDGER
    EXECUTE_PRINT_SIZE_STATEMENT
    EXECUTE_PRINT_SIZE_EXECUTIVE
    EXECUTE_PRINT_SIZE_A3
    EXECUTE_PRINT_SIZE_A4SMALL
    EXECUTE_PRINT_SIZE_A5
    EXECUTE_PRINT_SIZE_B4
    EXECUTE_PRINT_SIZE_B5
    EXECUTE_PRINT_SIZE_FOLIO
    EXECUTE_PRINT_SIZE_QUARTO
    EXECUTE_PRINT_SIZE_10X14
    EXECUTE_PRINT_SIZE_11X17
    EXECUTE_PRINT_SIZE_NOTE
    EXECUTE_PRINT_SIZE_ENV9
    EXECUTE_PRINT_SIZE_ENV10
    EXECUTE_PRINT_SIZE_ENV11
    EXECUTE_PRINT_SIZE_ENV12
    EXECUTE_PRINT_SIZE_ENV14
    EXECUTE_PRINT_SIZE_ENVDL
    EXECUTE_PRINT_SIZE_ENVC5
    EXECUTE_PRINT_SIZE_ENVC3
    EXECUTE_PRINT_SIZE_ENVC4
    EXECUTE_PRINT_SIZE_ENVC6
    EXECUTE_PRINT_SIZE_ENVC65
    EXECUTE_PRINT_SIZE_ENVB4
    EXECUTE_PRINT_SIZE_ENVB5
    EXECUTE_PRINT_SIZE_ENVB6
    EXECUTE_PRINT_SIZE_ENVITALY
    EXECUTE_PRINT_SIZE_ENVMONARCH
    EXECUTE_PRINT_SIZE_ENVPERSONAL
    EXECUTE_PRINT_SIZE_FANFOLD_US
    EXECUTE_PRINT_SIZE_FANFOLD_STDGERMAN
    EXECUTE_PRINT_SIZE_FANFOLD_LGLGERMAN
    EXECUTE_PRINT_SIZE_ISOB4
    EXECUTE_PRINT_SIZE_JAPANESE_POSTCARD
    EXECUTE_PRINT_SIZE_9X11
    EXECUTE_PRINT_SIZE_10X11
    EXECUTE_PRINT_SIZE_15X11
    EXECUTE_PRINT_SIZE_ENV_INVITE
    EXECUTE_PRINT_SIZE_LETTER_EXTRA
    EXECUTE_PRINT_SIZE_LEGAL_EXTRA
    EXECUTE_PRINT_SIZE_TABLOID_EXTRA
    EXECUTE_PRINT_SIZE_A4_EXTRA
    EXECUTE_PRINT_SIZE_LETTER_TRANSVERSE
    EXECUTE_PRINT_SIZE_A3_TRANSVERSE
    EXECUTE_PRINT_SIZE_A3_EXTRA_TRANSVERSE
    EXECUTE_PRINT_SIZE_A4_TRANSVERSE
    EXECUTE_PRINT_SIZE_LETTER_EXTRA_TRANSVERSE
    EXECUTE_PRINT_SIZE_A5_TRANSVERSE
    EXECUTE_PRINT_SIZE_B5_TRANSVERSE
    EXECUTE_PRINT_SIZE_A_PLUS
    EXECUTE_PRINT_SIZE_B_PLUS
    EXECUTE_PRINT_SIZE_LETTER_PLUS
    EXECUTE_PRINT_SIZE_A4_PLUS
    EXECUTE_PRINT_SIZE_A3_EXTRA
    EXECUTE_PRINT_SIZE_A5_EXTRA
    EXECUTE_PRINT_SIZE_B5_EXTRA
    EXECUTE_PRINT_SIZE_A2
    EXECUTE_PRINT_SIZE_USER
End Enum

Private Type ImageInfo
    WorldScale As Double
    Filename(255) As Byte
End Type

Private Type WindowState
    State As Long
End Type

Private Type ImageType
  Type As Long
End Type

Private Type OrientType
  Type As Long
End Type

Private Type NotifyCallbackRecord
    Message As Long 'The message ID for the notification
    DataStatus As Long 'The status of the data attached to the notification
    Data As Long  'The address of the data attached to the notification
End Type

Private Type NotifyInquireDocument
    clip(3) As Double 'current viewed area
    limits(3) As Double  'limits of the document
    markupfile(255) As Byte 'The editable markup file if one opened, NULL if no markup opened
    markupchanged As Long 'If the current editable markup has been changed
    description(255) As Byte 'extracted from the folder file
    docwindowsize(3) As Long 'The RECT associated with the image window
    docwindowposition(3) As Long 'The device location of the window image (RECT)
    docwindowstate As WindowState 'The state of the image window
    myrwindowsize(3) As Long 'the RECT associated with Myriad's main window
    myrwindowpos(3) As Long 'The device location of Myriad's main window
    myrwindowstate As WindowState 'The state of Myriad's main window
    numberofpages As Long 'The number of pages in the image
    activepage As Long 'Currently displayed page
    ImageType As ImageType  'Monochrome Raster, Color Raster, Vector, Text
    orientation As OrientType  'Orientation (rotation)
    resolution As Long 'DPI
    reserved As Long 'Four byte field for correct compiler structure padding in 16 and 32 bit environments
    numberoffiles As Long 'Number of entries in the filepath array of files
    ImageInfo(0) As ImageInfo 'For all images (first entry and subsequent overlays): full path and worldscale
End Type

Dim PrevProc As Long, pCallBackRecord As NotifyCallbackRecord
'---------------- my test vars ------------------------------
'Private Const OFFSET_4 = 4294967296#
'Private Const MAXINT_4 = 2147483647
'Private Const OFFSET_2 = 65536
'Private Const MAXINT_2 = 32767
Dim str As String
Dim i As Integer
Dim b As Byte
Dim newDub As Double
'------------------------------------------------------------

Public Sub HookForm(f As Form)
PrevProc = SetWindowLong(f.hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub UnHookForm(f As Form)
SetWindowLong f.hWnd, GWL_WNDPROC, PrevProc
End Sub

Private Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
WindowProc = CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
If uMsg = IGC_NOTIFY_CALLBACK_MESSAGE Then
'------------- my debug code ------------------------------------
            For i = 0 To LenB(pCallBackRecord) - 1
                CopyMemory b, ByVal lParam + i, 1
                str = str & b & ","
            Next i


            str = Left$(str, Len(str) - 1)
            bites = Split(str, ",")
            h0 = Hex(bites(11))
            h1 = Hex(bites(10))
            h2 = Hex(bites(9))
            h3 = Hex(bites(8))
            On Error Resume Next
            newDub = CDbl("&H" & h0 & h1 & h2 & h3)
            If newDub < 0 Then
            'remove the most significant bit (negative flag)
            newDub = newDub And Not &H80000000
            'now subtract the smallest allowable long number value
            'to add in the long number negative flag (&h80000000) as a positive value
            newDub = newDub - CDbl("&h80000000")
            End If

            Open App.Path & "\dumplog.txt" For Output As #1
            Write #1, str, newDub
            Close #1
'----------------------------------------------------------------
    CopyMemory pCallBackRecord, ByVal lParam, ByVal LenB(pCallBackRecord)
    MsgBox "procdata: " & pCallBackRecord.Message & "," & pCallBackRecord.DataStatus & "," & pCallBackRecord.Data
    processData
End If
End Function

Private Sub processData()
Dim pRecord As NotifyInquireDocument
Dim myStr As String, longval As Long

myStr = String(256, 0)
Select Case pCallBackRecord.Message
    Case INTG_NOTIFY_DOCUMENT_INFO
        If pCallBackRecord.DataStatus = INTG_STATUS_COMPLETE_DATA Then
            MsgBox "copying data value: " & pCallBackRecord.Data & " len prec:" & LenB(pRecord)

            'unsuccessful attempt at converting the address...
'            If pCallBackRecord.Data < 0 Then
'               longval = CLng(&H7FFFFFFF And pCallBackRecord.Data) - 1
'            Else
'               longval = pCallBackRecord.Data
'            End If
'            MsgBox "longval:" & longval
'            CopyMemory3 pRecord, longval, ByVal LenB(pRecord)
'MsgBox "copymem newdub:" & newDub
'CopyMemory3 pRecord, newDub, ByVal LenB(pRecord)
            CopyMemory2 pRecord, pCallBackRecord.Data, ByVal LenB(pRecord)
            With Form1.Text2
            .Text = ""
            .Text = "clip: " & pRecord.clip(0) & " , " & pRecord.clip(1) & " , " & pRecord.clip(2) & " , " & pRecord.clip(3) & vbCrLf
            .Text = .Text & "limits: " & pRecord.limits(0) & " , " & pRecord.limits(1) & " , " & pRecord.limits(2) & " , " & pRecord.limits(3) & vbCrLf
            CopyMemory3 myStr, pRecord.markupfile(0), ByVal LenB(myStr)
            .Text = .Text & "markupfile: " & myStr & vbCrLf
            .Text = .Text & "markupchanged: " & pRecord.markupchanged & vbCrLf
            CopyMemory3 myStr, pRecord.description(0), ByVal LenB(myStr)
            .Text = .Text & "desc: " & myStr & vbCrLf
            .Text = .Text & "docwindowsize: " & pRecord.docwindowsize(0) & " , " & pRecord.docwindowsize(1) & " , " & pRecord.docwindowsize(2) & " , " & pRecord.docwindowsize(3) & vbCrLf
            .Text = .Text & "docwindowposition: " & pRecord.docwindowposition(0) & " , " & pRecord.docwindowposition(1) & " , " & pRecord.docwindowposition(2) & " , " & pRecord.docwindowposition(3) & vbCrLf
            .Text = .Text & "docwindowstate: " & pRecord.docwindowstate.State & vbCrLf
            .Text = .Text & "myrwinpos: " & pRecord.myrwindowpos(0) & " , " & pRecord.myrwindowpos(1) & " , " & pRecord.myrwindowpos(2) & " , " & pRecord.myrwindowpos(3) & vbCrLf
            .Text = .Text & "winstate: " & pRecord.myrwindowstate.State & vbCrLf
            .Text = .Text & "numpgs: " & pRecord.numberofpages & vbCrLf
            .Text = .Text & "activepage: " & pRecord.activepage & vbCrLf
            .Text = .Text & "ImageType: " & pRecord.ImageType.Type & vbCrLf
            .Text = .Text & "orientation: " & pRecord.orientation.Type & vbCrLf
            .Text = .Text & "resolution: " & pRecord.resolution & vbCrLf
            .Text = .Text & "reserved: " & pRecord.reserved & vbCrLf
            .Text = .Text & "numberoffiles: " & pRecord.numberoffiles & vbCrLf
            CopyMemory3 myStr, pRecord.ImageInfo(0).Filename(0), ByVal LenB(myStr)
            .Text = .Text & "ImageInfoFilename: " & myStr & vbCrLf
            .Text = .Text & "ImageInfoWorldScale: " & pRecord.ImageInfo(0).WorldScale
            End With
         End If
'    Case INTG_NOTIFY_SYSTEM_INFO
End Select
End Sub



0
 
LVL 1

Author Comment

by:wehoit
ID: 8036324
Okay - You asked for it -

/* THIS IS A COMPOSITE OF SEVERAL .H AND .C FILES TO SHOW THE MAIN
    CODE I'M INTERESTED IN....
   
#ifndef IGENUM    
#  ifdef __WIN32
    typedef int IGENUM;
#  else
    typedef long IGENUM;
#  endif
#endif

#ifndef IGINT
#  ifdef __WIN32
    typedef int IGINT;
#  else
    typedef long IGINT;
#  endif
#endif

#ifndef IGBOOL
  #ifdef __WIN32
    typedef int IGBOOL;
  #else
    typedef long IGBOOL;
  #endif
#endif

#define MAX_STRING                                         (256)
#define IGC_NOTIFY_CALLBACK_MESSAGE     (WM_USER+10000

/* I HAVE REMOVED MOST OF THE CONTENT OF THE ENUMS TO MAKE THIS EASIER TO READ THROUGH.....
           
/* This enumerated type is used to identify the execution command */
typedef enum {INTG_EXECUTE_NOTIFY_RETURN,
              INTG_EXECUTE_INQUIRE_DOCUMENT,
              INTG_EXECUTE_INQUIRE_SYSTEM,
             }ExecutionCommandType;

/* These are the notification message types which identify the type of  */
/* data packet being received by the integrating application            */
typedef enum {INTG_NOTIFY_NONE,
              INTG_NOTIFY_DOCUMENT_INFO,
             }NotifyMessageType;

/* This structure is used to retrieve the data passed from Myriad in the form of a notification message */
struct NotifyCallbackRecord{
  IGBOOL               Message;             /* The message ID for the notification                    */
  IGBOOL               DataStatus;          /* The status of the data attached to the notification    */
  char                 Data;                /* The address of the data attached to the notification   */
};

typedef enum {
      MONOCHROME_RASTER,
      COLOR_RASTER,
      VECTOR,
      TEXT
} ImageTypesEnum;

typedef struct {
  IGENUM Type;
} ImageType;

typedef enum {
    DEGREES_0,
    DEGREES_90,
    DEGREES_180,
    DEGREES_270
} OrientTypesEnum;

typedef struct {
      IGENUM Type;
} OrientType;

typedef enum {
  WINDOW_MINIMIZED,
  WINDOW_MAXIMIZED,
  WINDOW_WINDOWED
} WindowStateEnum;

typedef struct {
      IGENUM State;
} WindowState;

typedef struct {
      double WorldScale;
      char   Filename[MAX_PATH_FILENAME];
} ImageInfo, *pImageInfo;

typedef struct NotifyInquireDocument{
      double      Clip[4];                               /* current viewed area */
      double      Limits[4];                             /* limits of the document */
      char        MarkupFile[MAX_PATH_FILENAME];         /* The editable markup file if one opened, NULL if no markup opened */
  IGBOOL      MarkupChanged;                         /* If the current editable markup has been changed */
      char        Description[INQUIRE_DESCRIPTION_SIZE]; /* extracted from the folder file */      
      IGINT       DocWindowSize[4];                      /* The RECT associated with the image window */
      IGINT       DocWindowPosition[4];                  /* The device location of the window image (RECT) */
  WindowState DocWindowState;                        /* The state of the image window */
      IGINT       MyrWindowSize[4];                      /* The RECT associated with Myriad's main window */
      IGINT       MyrWindowPosition[4];                  /* The device location of Myriad's main window */
  WindowState MyrWindowState;                        /* The state of Myriad's main window */
      IGINT       NumberOfPages;                         /* The number of pages in the image */
      IGINT       ActivePage;                            /* Currently displayed page */
      ImageType   ImageType;                             /* Monochrome Raster, Color Raster, Vector, Text */
      OrientType  Orientation;                           /* Orientation (rotation)*/
      IGINT       Resolution;                            /* DPI */
      IGINT       Reserved;                              /* Four byte field for correct compiler structure padding in 16 and 32 bit environments */
      IGINT       NumberOfFiles;                         /* Number of entries in the filepath array of files */
      ImageInfo   ImageInfo[1];                          /* For all images (first entry and subsequent overlays): full path and worldscale */
} NotifyInquireDocument, *pNotifyInquireDocument;


/* THIS IS THE INITIAL COMMAND ISSUED TO START THE CALLBACK.....
void doInquireDocument(BOOL bUseCommandString)
{
       char ExecutionString[MAX_STRING];

   if(!IsServerUp()){
      PrintLine("There is no connection to Myriad.");
      return;
   }

   if(bUseCommandString){
      PrintLine("Sending Inquire Document string to Myriad...");

      // Setup the execution string
     strcpy(ExecutionString, "inquire_document()");

     if(ProcessExecutionString(ExecutionString)){
         PrintLine("--> Inquire Document succeeded.");
     }else{
         PrintLine("--> Inquire Document failed.");
     }
  }else{
     PrintLine("Sending Inquire Document to Myriad...");

     if(ProcessExecutionCommand(INTG_EXECUTE_INQUIRE_DOCUMENT, NULL)){
        PrintLine("--> Inquire Document succeeded.");
     }else{
        PrintLine("--> Inquire Document failed.");
     }
  }
}


long FAR PASCAL WndProc(HWND hWnd, unsigned iMessage, WORD wParam, LONG lParam)
{
   int ret=0;
   int rc=TRUE;

   switch (iMessage){
      case WM_PAINT:{
         PaintWindow();
     }
     break;

      case IGC_NOTIFY_CALLBACK_MESSAGE:{
        NotifyCallbackHandler((struct NotifyCallbackRecord *)lParam);
     }
     break;

      case WM_COMMAND:{
         switch (wParam){
          case IDM_COMMAND_COMMAND_INQUIRE_DOCUMENT:{
                 doInquireDocument(FALSE);
            }
             break;
        default:{
         return DefWindowProc(hWnd, iMessage, wParam, lParam);
      }
   }

   return(FALSE);
}

// Callback handler for notification messages
void NotifyCallbackHandler(struct NotifyCallbackRecord *pCallbackRecord)
{
   char tempstring[MAX_STRING];
   
   switch(pCallbackRecord->Message){
         case INTG_NOTIFY_DOCUMENT_INFO: {
         HandleInquireDocumentPrint(&pCallbackRecord->Data);
      }
      break;
      default:{
         sprintf(tempstring, ">>> Received unhandled notify message %d", (int)pCallbackRecord->Message);
         PrintLine(tempstring);
      }
      break;
   }
}

void HandleInquireDocumentPrint(void *pData)
{
   pNotifyInquireDocument pRecord;
   char                   tempString[MAX_STRING];
   pImageInfo             ptr;
   int                    i;


   if ((pRecord = pData) != NULL) {
      sprintf(tempString, ">>> Inquire Document Info: ");
      PrintLine(tempString);

      if (pRecord->MarkupFile[0] != '\0') {
         sprintf(tempString, "Markup file: %s", pRecord->MarkupFile);
         PrintLine(tempString);
         if (pRecord->MarkupChanged)
            sprintf(tempString, "Markup file has been changed");
         else
            sprintf(tempString, "Markup file has not been changed");
         PrintLine(tempString);
      }
      else {
         sprintf(tempString, "Markup file: None");
         PrintLine(tempString);
      }

      sprintf(tempString, "Description: %s", pRecord->Description);
      PrintLine(tempString);

      sprintf(tempString, "Current viewed area (clip): %lf, %lf, %lf, %lf", pRecord->Clip[0],
                           pRecord->Clip[1], pRecord->Clip[2], pRecord->Clip[3]);
      PrintLine(tempString);

      sprintf(tempString, "Limits of the document: %lf, %lf, %lf, %lf", pRecord->Limits[0],
                           pRecord->Limits[1], pRecord->Limits[2], pRecord->Limits[3]);
      PrintLine(tempString);

      sprintf(tempString, "Document window size: %ld, %ld, %ld, %ld", pRecord->DocWindowSize[0],
         pRecord->DocWindowSize[1], pRecord->DocWindowSize[2], pRecord->DocWindowSize[3]);
      PrintLine(tempString);

      sprintf(tempString, "Document window position: %ld, %ld, %ld, %ld", pRecord->DocWindowPosition[0],
         pRecord->DocWindowPosition[1], pRecord->DocWindowPosition[2], pRecord->DocWindowPosition[3]);
      PrintLine(tempString);

     strcpy(tempString, "Document window state: ");

     switch(pRecord->DocWindowState.State){
        case WINDOW_MINIMIZED : strcat(tempString, "Minimized");break;
        case WINDOW_MAXIMIZED : strcat(tempString, "Maximized");break;
        case WINDOW_WINDOWED  : strcat(tempString, "Windowed");break;
     }

     PrintLine(tempString);

      sprintf(tempString, "Myriad window size: %ld, %ld, %ld, %ld", pRecord->MyrWindowSize[0],
         pRecord->MyrWindowSize[1], pRecord->MyrWindowSize[2], pRecord->MyrWindowSize[3]);
      PrintLine(tempString);

      sprintf(tempString, "Myriad window position: %ld, %ld, %ld, %ld", pRecord->MyrWindowPosition[0],
         pRecord->MyrWindowPosition[1], pRecord->MyrWindowPosition[2], pRecord->MyrWindowPosition[3]);
      PrintLine(tempString);

     strcpy(tempString, "Myriad window state: ");

     switch(pRecord->MyrWindowState.State){
        case WINDOW_MINIMIZED : strcat(tempString, "Minimized");break;
        case WINDOW_MAXIMIZED : strcat(tempString, "Maximized");break;
        case WINDOW_WINDOWED  : strcat(tempString, "Windowed");break;
     }

     PrintLine(tempString);

      sprintf(tempString, "Number of pages: %ld", pRecord->NumberOfPages);
      PrintLine(tempString);

      sprintf(tempString, "Active page: %ld", pRecord->ActivePage);
      PrintLine(tempString);

      sprintf(tempString, "Image type: ");
      switch (pRecord->ImageType.Type) {
         case MONOCHROME_RASTER: strcat(tempString, "Monochrome Raster"); break;
         case COLOR_RASTER: strcat(tempString, "Color Raster"); break;
      case VECTOR: strcat(tempString, "Vector"); break;
         case TEXT: strcat(tempString, "Text"); break;
      }
      PrintLine(tempString);

      sprintf(tempString, "Orientation: ");
      switch (pRecord->Orientation.Type) {
      case DEGREES_0: strcat(tempString, "0 Degrees"); break;
         case DEGREES_90: strcat(tempString, "90 Degrees"); break;
      case DEGREES_180: strcat(tempString, "180 Degrees"); break;
         case DEGREES_270: strcat(tempString, "270 Degrees"); break;
      }
      PrintLine(tempString);

      sprintf(tempString, "Resolution: %ld", pRecord->Resolution);
      PrintLine(tempString);

      sprintf(tempString, "Number of files: %ld", pRecord->NumberOfFiles);
      PrintLine(tempString);

      sprintf(tempString, "Files:");
      PrintLine(tempString);

      ptr = pRecord->ImageInfo;
   
      for (i = 0; i < pRecord->NumberOfFiles; i++) {
         sprintf(tempString, "Name:%s  World Scale:%lf", ptr->Filename, ptr->WorldScale);
         PrintLine(tempString);
         ptr++;
      }
         
   } else {
      PrintLine(">>> Notify Inquire Document (Invalid data packet)");
   }
}



Now, Here's my VB vesrsion:
Public Declare Function StartAndInitServer Lib ".\myrcmd32.dll" (ByVal ServerName As String) As Boolean
Public Declare Function IsServerUp Lib "myrcmd32.dll" () As Boolean
Public Declare Function ProcessExecutionString Lib "myrcmd32.dll" (ByVal pString As String) As Boolean
Public Declare Function SetNotifyWindow Lib "myrcmd32.dll" (ByVal hWnd As Long) As Boolean

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Three versions for testing
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Long, ByVal cbCopy As Long)
Private Declare Sub CopyMemory3 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Double, ByVal cbCopy As Long)

Public Const MYRIAD_EXECUTABLE_NAME As String = "myriad32.exe"
Private Const GWL_WNDPROC = (-4)
Private Const WM_USER As Long = &H400
Private Const IGC_NOTIFY_CALLBACK_MESSAGE  As Long = (WM_USER + 10000)

Private Enum isostrings
    EXECUTE_ISO_FONT
    EXECUTE_ISO_CLEAR_ALL
    EXECUTE_ISO_RESTORE_DEFAULTS
    EXECUTE_ISO_TOPLEFT
    EXECUTE_ISO_TOPCENTER
    EXECUTE_ISO_TOPRIGHT
    EXECUTE_ISO_BOTTOMLEFT
    EXECUTE_ISO_BOTTOMCENTER
    EXECUTE_ISO_BOTTOMRIGHT
    EXECUTE_ISO_LEFTTOP
    EXECUTE_ISO_LEFTCENTER
    EXECUTE_ISO_LEFTBOTTOM
    EXECUTE_ISO_RIGHTTOP
    EXECUTE_ISO_RIGHTCENTER
    EXECUTE_ISO_RIGHTBOTTOM
    EXECUTE_ISO_WATERMARK
End Enum

Private Enum DataStatusType
    INTG_STATUS_COMPLETE_DATA
    INTG_STATUS_PARTIAL_DATA
    INTG_STATUS_NO_DATA
    INTG_STATUS_REPLY_REQUESTED
End Enum

Private Enum ExecutePrintScaleTypes
    EXECUTE_PRINT_SCALE_PAGE
    EXECUTE_PRINT_SCALE_TO_SCALE
End Enum

Private Enum ExecutePrintRangeTypes
    EXECUTE_PRINT_RANGE_ALL
    EXECUTE_PRINT_RANGE_PAGES
    EXECUTE_PRINT_RANGE_CURRENT
End Enum

Private Enum ExecutePrintOrientTypes
    EXECUTE_PRINT_ORIENT_PORTRAIT
    EXECUTE_PRINT_ORIENT_LANDSCAPE
End Enum

Private Enum ExecutePrintPrintWhatTypes
    EXECUTE_PRINT_DOCUMENT
    EXECUTE_PRINT_NOTES
End Enum

' These are the notification message types which identify the type of
' data packet being received by the integrating application
Private Enum NotifyMessageType
    INTG_NOTIFY_NONE
    INTG_NOTIFY_EXECUTION_RETURN
    INTG_NOTIFY_MOUSEMOVE
    INTG_NOTIFY_LBUTTONDOWN
    INTG_NOTIFY_LBUTTONUP
    INTG_NOTIFY_LBUTTONDBLCLICK
    INTG_NOTIFY_EXIT
    INTG_LOAD_FILEBEGIN
    INTG_LOAD_BLOCKBEGIN
    INTG_LOAD_ATTRIBUTE
    INTG_LOAD_BLOCKEND
    INTG_LOAD_FILEEND
    INTG_DISPLAY_FILEBEGIN
    INTG_DISPLAY_BLOCKBEGIN
    INTG_DISPLAY_ATTRIBUTE
    INTG_DISPLAY_BLOCKEND
    INTG_DISPLAY_FILEEND
    INTG_LAUNCH_ATTRIBBLOCK
    INTG_NOTIFY_SET_RETURN_DATA
    INTG_NOTIFY_FILE_LOADED
    INTG_NOTIFY_VIEWPORT_CLOSE
    INTG_NOTIFY_OPEN_MARKUP
    INTG_NOTIFY_SAVE_MARKUP
    INTG_NOTIFY_MARKUP_SAVED
    INTG_NOTIFY_CLOSE_MARKUP
    INTG_NOTIFY_IMAGE_CHANGE
    INTG_NOTIFY_GET_LAYER_INFO
    INTG_NOTIFY_GET_ISO_STRING
    INTG_NOTIFY_DATABASE_LOOKUP
    INTG_NOTIFY_PRINT
    INTG_NOTIFY_PRINT_COMPLETE
    INTG_NOTIFY_UD_MENU
    INTG_NOTIFY_OPEN_MARKUP_REQUEST
    INTG_NOTIFY_DOCUMENT_INFO
    INTG_NOTIFY_SYSTEM_INFO
    INTG_NOTIFY_SAVEAS_MARKUP_REQUEST
    INTG_NOTIFY_GET_AUTHORS
    INTG_NOTIFY_CHANGEMARK_VIEWED
    INTG_NOTIFY_GET_CHANGEMARKS
    INTG_NOTIFY_NEW_MARKUP
    INTG_NOTIFY_RUN_SILENT_MSG
    INTG_NOTIFY_ISO_DISPLAY
    INTG_NOTIFY_ISO_EDIT
    INTG_NOTIFY_DATABASE_ISO_LOOKUP
    INTG_NOTIFY_INTEGRATION_ENABLED
    INTG_NOTIFY_3D_MODEL_LOADED
    INTG_NOTIFY_3D_COMPONENT_SELECTION_CHANGED
    INTG_NOTIFY_3D_COMPONENT_LIST_ENABLED
    INTG_NOTIFY_PRINT_PREVIEW_COMPLETE
    INTG_NOTIFY_OPEN_MVS_REQUEST
    INTG_NOTIFY_SAVEAS_MVS_REQUEST
    INTG_NOTIFY_MVS_SAVED
    INTG_NOTIFY_CLOSE_MVS
    INTG_NOTIFY_HTML_EXPORT_FILE_WRITTEN
    INTG_NOTIFY_MVS_VIEW_CREATED
    INTG_NOTIFY_VIEW_SET_FILE_LOADED
    INTG_NOTIFY_VIEW_SET_NEEDS_SAVING
End Enum

Private Enum ExecutePrintPaperSizeTypes
    EXECUTE_PRINT_SIZE_DEFAULT
    EXECUTE_PRINT_SIZE_LETTER
    EXECUTE_PRINT_SIZE_LEGAL
    EXECUTE_PRINT_SIZE_A4
    EXECUTE_PRINT_SIZE_CSHEET
    EXECUTE_PRINT_SIZE_DSHEET
    EXECUTE_PRINT_SIZE_ESHEET
    EXECUTE_PRINT_SIZE_LETTERSMALL
    EXECUTE_PRINT_SIZE_TABLOID
    EXECUTE_PRINT_SIZE_LEDGER
    EXECUTE_PRINT_SIZE_STATEMENT
    EXECUTE_PRINT_SIZE_EXECUTIVE
    EXECUTE_PRINT_SIZE_A3
    EXECUTE_PRINT_SIZE_A4SMALL
    EXECUTE_PRINT_SIZE_A5
    EXECUTE_PRINT_SIZE_B4
    EXECUTE_PRINT_SIZE_B5
    EXECUTE_PRINT_SIZE_FOLIO
    EXECUTE_PRINT_SIZE_QUARTO
    EXECUTE_PRINT_SIZE_10X14
    EXECUTE_PRINT_SIZE_11X17
    EXECUTE_PRINT_SIZE_NOTE
    EXECUTE_PRINT_SIZE_ENV9
    EXECUTE_PRINT_SIZE_ENV10
    EXECUTE_PRINT_SIZE_ENV11
    EXECUTE_PRINT_SIZE_ENV12
    EXECUTE_PRINT_SIZE_ENV14
    EXECUTE_PRINT_SIZE_ENVDL
    EXECUTE_PRINT_SIZE_ENVC5
    EXECUTE_PRINT_SIZE_ENVC3
    EXECUTE_PRINT_SIZE_ENVC4
    EXECUTE_PRINT_SIZE_ENVC6
    EXECUTE_PRINT_SIZE_ENVC65
    EXECUTE_PRINT_SIZE_ENVB4
    EXECUTE_PRINT_SIZE_ENVB5
    EXECUTE_PRINT_SIZE_ENVB6
    EXECUTE_PRINT_SIZE_ENVITALY
    EXECUTE_PRINT_SIZE_ENVMONARCH
    EXECUTE_PRINT_SIZE_ENVPERSONAL
    EXECUTE_PRINT_SIZE_FANFOLD_US
    EXECUTE_PRINT_SIZE_FANFOLD_STDGERMAN
    EXECUTE_PRINT_SIZE_FANFOLD_LGLGERMAN
    EXECUTE_PRINT_SIZE_ISOB4
    EXECUTE_PRINT_SIZE_JAPANESE_POSTCARD
    EXECUTE_PRINT_SIZE_9X11
    EXECUTE_PRINT_SIZE_10X11
    EXECUTE_PRINT_SIZE_15X11
    EXECUTE_PRINT_SIZE_ENV_INVITE
    EXECUTE_PRINT_SIZE_LETTER_EXTRA
    EXECUTE_PRINT_SIZE_LEGAL_EXTRA
    EXECUTE_PRINT_SIZE_TABLOID_EXTRA
    EXECUTE_PRINT_SIZE_A4_EXTRA
    EXECUTE_PRINT_SIZE_LETTER_TRANSVERSE
    EXECUTE_PRINT_SIZE_A3_TRANSVERSE
    EXECUTE_PRINT_SIZE_A3_EXTRA_TRANSVERSE
    EXECUTE_PRINT_SIZE_A4_TRANSVERSE
    EXECUTE_PRINT_SIZE_LETTER_EXTRA_TRANSVERSE
    EXECUTE_PRINT_SIZE_A5_TRANSVERSE
    EXECUTE_PRINT_SIZE_B5_TRANSVERSE
    EXECUTE_PRINT_SIZE_A_PLUS
    EXECUTE_PRINT_SIZE_B_PLUS
    EXECUTE_PRINT_SIZE_LETTER_PLUS
    EXECUTE_PRINT_SIZE_A4_PLUS
    EXECUTE_PRINT_SIZE_A3_EXTRA
    EXECUTE_PRINT_SIZE_A5_EXTRA
    EXECUTE_PRINT_SIZE_B5_EXTRA
    EXECUTE_PRINT_SIZE_A2
    EXECUTE_PRINT_SIZE_USER
End Enum

Private Type ImageInfo
    WorldScale As Double
    Filename(255) As Byte
End Type

Private Type WindowState
    State As Long
End Type

Private Type ImageType
  Type As Long
End Type

Private Type OrientType
  Type As Long
End Type

Private Type NotifyCallbackRecord
    Message As Long 'The message ID for the notification
    DataStatus As Long 'The status of the data attached to the notification
    Data As Long  'The address of the data attached to the notification
End Type

Private Type NotifyInquireDocument
    clip(3) As Double 'current viewed area
    limits(3) As Double  'limits of the document
    markupfile(255) As Byte 'The editable markup file if one opened, NULL if no markup opened
    markupchanged As Long 'If the current editable markup has been changed
    description(255) As Byte 'extracted from the folder file
    docwindowsize(3) As Long 'The RECT associated with the image window
    docwindowposition(3) As Long 'The device location of the window image (RECT)
    docwindowstate As WindowState 'The state of the image window
    myrwindowsize(3) As Long 'the RECT associated with Myriad's main window
    myrwindowpos(3) As Long 'The device location of Myriad's main window
    myrwindowstate As WindowState 'The state of Myriad's main window
    numberofpages As Long 'The number of pages in the image
    activepage As Long 'Currently displayed page
    ImageType As ImageType  'Monochrome Raster, Color Raster, Vector, Text
    orientation As OrientType  'Orientation (rotation)
    resolution As Long 'DPI
    reserved As Long 'Four byte field for correct compiler structure padding in 16 and 32 bit environments
    numberoffiles As Long 'Number of entries in the filepath array of files
    ImageInfo(0) As ImageInfo 'For all images (first entry and subsequent overlays): full path and worldscale
End Type

Dim PrevProc As Long, pCallBackRecord As NotifyCallbackRecord
'---------------- my test vars ------------------------------
'Private Const OFFSET_4 = 4294967296#
'Private Const MAXINT_4 = 2147483647
'Private Const OFFSET_2 = 65536
'Private Const MAXINT_2 = 32767
Dim str As String
Dim i As Integer
Dim b As Byte
Dim newDub As Double
'------------------------------------------------------------

Public Sub HookForm(f As Form)
PrevProc = SetWindowLong(f.hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub UnHookForm(f As Form)
SetWindowLong f.hWnd, GWL_WNDPROC, PrevProc
End Sub

Private Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
WindowProc = CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
If uMsg = IGC_NOTIFY_CALLBACK_MESSAGE Then
'------------- my debug code ------------------------------------
            For i = 0 To LenB(pCallBackRecord) - 1
                CopyMemory b, ByVal lParam + i, 1
                str = str & b & ","
            Next i


            str = Left$(str, Len(str) - 1)
            bites = Split(str, ",")
            h0 = Hex(bites(11))
            h1 = Hex(bites(10))
            h2 = Hex(bites(9))
            h3 = Hex(bites(8))
            On Error Resume Next
            newDub = CDbl("&H" & h0 & h1 & h2 & h3)
            If newDub < 0 Then
            'remove the most significant bit (negative flag)
            newDub = newDub And Not &H80000000
            'now subtract the smallest allowable long number value
            'to add in the long number negative flag (&h80000000) as a positive value
            newDub = newDub - CDbl("&h80000000")
            End If

            Open App.Path & "\dumplog.txt" For Output As #1
            Write #1, str, newDub
            Close #1
'----------------------------------------------------------------
    CopyMemory pCallBackRecord, ByVal lParam, ByVal LenB(pCallBackRecord)
    MsgBox "procdata: " & pCallBackRecord.Message & "," & pCallBackRecord.DataStatus & "," & pCallBackRecord.Data
    processData
End If
End Function

Private Sub processData()
Dim pRecord As NotifyInquireDocument
Dim myStr As String, longval As Long

myStr = String(256, 0)
Select Case pCallBackRecord.Message
    Case INTG_NOTIFY_DOCUMENT_INFO
        If pCallBackRecord.DataStatus = INTG_STATUS_COMPLETE_DATA Then
            MsgBox "copying data value: " & pCallBackRecord.Data & " len prec:" & LenB(pRecord)

            'unsuccessful attempt at converting the address...
'            If pCallBackRecord.Data < 0 Then
'               longval = CLng(&H7FFFFFFF And pCallBackRecord.Data) - 1
'            Else
'               longval = pCallBackRecord.Data
'            End If
'            MsgBox "longval:" & longval
'            CopyMemory3 pRecord, longval, ByVal LenB(pRecord)
'MsgBox "copymem newdub:" & newDub
'CopyMemory3 pRecord, newDub, ByVal LenB(pRecord)
            CopyMemory2 pRecord, pCallBackRecord.Data, ByVal LenB(pRecord)
            With Form1.Text2
            .Text = ""
            .Text = "clip: " & pRecord.clip(0) & " , " & pRecord.clip(1) & " , " & pRecord.clip(2) & " , " & pRecord.clip(3) & vbCrLf
            .Text = .Text & "limits: " & pRecord.limits(0) & " , " & pRecord.limits(1) & " , " & pRecord.limits(2) & " , " & pRecord.limits(3) & vbCrLf
            CopyMemory3 myStr, pRecord.markupfile(0), ByVal LenB(myStr)
            .Text = .Text & "markupfile: " & myStr & vbCrLf
            .Text = .Text & "markupchanged: " & pRecord.markupchanged & vbCrLf
            CopyMemory3 myStr, pRecord.description(0), ByVal LenB(myStr)
            .Text = .Text & "desc: " & myStr & vbCrLf
            .Text = .Text & "docwindowsize: " & pRecord.docwindowsize(0) & " , " & pRecord.docwindowsize(1) & " , " & pRecord.docwindowsize(2) & " , " & pRecord.docwindowsize(3) & vbCrLf
            .Text = .Text & "docwindowposition: " & pRecord.docwindowposition(0) & " , " & pRecord.docwindowposition(1) & " , " & pRecord.docwindowposition(2) & " , " & pRecord.docwindowposition(3) & vbCrLf
            .Text = .Text & "docwindowstate: " & pRecord.docwindowstate.State & vbCrLf
            .Text = .Text & "myrwinpos: " & pRecord.myrwindowpos(0) & " , " & pRecord.myrwindowpos(1) & " , " & pRecord.myrwindowpos(2) & " , " & pRecord.myrwindowpos(3) & vbCrLf
            .Text = .Text & "winstate: " & pRecord.myrwindowstate.State & vbCrLf
            .Text = .Text & "numpgs: " & pRecord.numberofpages & vbCrLf
            .Text = .Text & "activepage: " & pRecord.activepage & vbCrLf
            .Text = .Text & "ImageType: " & pRecord.ImageType.Type & vbCrLf
            .Text = .Text & "orientation: " & pRecord.orientation.Type & vbCrLf
            .Text = .Text & "resolution: " & pRecord.resolution & vbCrLf
            .Text = .Text & "reserved: " & pRecord.reserved & vbCrLf
            .Text = .Text & "numberoffiles: " & pRecord.numberoffiles & vbCrLf
            CopyMemory3 myStr, pRecord.ImageInfo(0).Filename(0), ByVal LenB(myStr)
            .Text = .Text & "ImageInfoFilename: " & myStr & vbCrLf
            .Text = .Text & "ImageInfoWorldScale: " & pRecord.ImageInfo(0).WorldScale
            End With
         End If
'    Case INTG_NOTIFY_SYSTEM_INFO
End Select
End Sub



0
 
LVL 1

Author Comment

by:wehoit
ID: 8036377
Okay - You asked for it -

/* THIS IS A COMPOSITE OF SEVERAL .H AND .C FILES TO SHOW THE MAIN
    CODE I'M INTERESTED IN....
   
#ifndef IGENUM    
#  ifdef __WIN32
    typedef int IGENUM;
#  else
    typedef long IGENUM;
#  endif
#endif

#ifndef IGINT
#  ifdef __WIN32
    typedef int IGINT;
#  else
    typedef long IGINT;
#  endif
#endif

#ifndef IGBOOL
  #ifdef __WIN32
    typedef int IGBOOL;
  #else
    typedef long IGBOOL;
  #endif
#endif

#define MAX_STRING                                         (256)
#define IGC_NOTIFY_CALLBACK_MESSAGE     (WM_USER+10000

/* I HAVE REMOVED MOST OF THE CONTENT OF THE ENUMS TO MAKE THIS EASIER TO READ THROUGH.....
           
/* This enumerated type is used to identify the execution command */
typedef enum {INTG_EXECUTE_NOTIFY_RETURN,
              INTG_EXECUTE_INQUIRE_DOCUMENT,
              INTG_EXECUTE_INQUIRE_SYSTEM,
             }ExecutionCommandType;

/* These are the notification message types which identify the type of  */
/* data packet being received by the integrating application            */
typedef enum {INTG_NOTIFY_NONE,
              INTG_NOTIFY_DOCUMENT_INFO,
             }NotifyMessageType;

/* This structure is used to retrieve the data passed from Myriad in the form of a notification message */
struct NotifyCallbackRecord{
  IGBOOL               Message;             /* The message ID for the notification                    */
  IGBOOL               DataStatus;          /* The status of the data attached to the notification    */
  char                 Data;                /* The address of the data attached to the notification   */
};

typedef enum {
      MONOCHROME_RASTER,
      COLOR_RASTER,
      VECTOR,
      TEXT
} ImageTypesEnum;

typedef struct {
  IGENUM Type;
} ImageType;

typedef enum {
    DEGREES_0,
    DEGREES_90,
    DEGREES_180,
    DEGREES_270
} OrientTypesEnum;

typedef struct {
      IGENUM Type;
} OrientType;

typedef enum {
  WINDOW_MINIMIZED,
  WINDOW_MAXIMIZED,
  WINDOW_WINDOWED
} WindowStateEnum;

typedef struct {
      IGENUM State;
} WindowState;

typedef struct {
      double WorldScale;
      char   Filename[MAX_PATH_FILENAME];
} ImageInfo, *pImageInfo;

typedef struct NotifyInquireDocument{
      double      Clip[4];                               /* current viewed area */
      double      Limits[4];                             /* limits of the document */
      char        MarkupFile[MAX_PATH_FILENAME];         /* The editable markup file if one opened, NULL if no markup opened */
  IGBOOL      MarkupChanged;                         /* If the current editable markup has been changed */
      char        Description[INQUIRE_DESCRIPTION_SIZE]; /* extracted from the folder file */      
      IGINT       DocWindowSize[4];                      /* The RECT associated with the image window */
      IGINT       DocWindowPosition[4];                  /* The device location of the window image (RECT) */
  WindowState DocWindowState;                        /* The state of the image window */
      IGINT       MyrWindowSize[4];                      /* The RECT associated with Myriad's main window */
      IGINT       MyrWindowPosition[4];                  /* The device location of Myriad's main window */
  WindowState MyrWindowState;                        /* The state of Myriad's main window */
      IGINT       NumberOfPages;                         /* The number of pages in the image */
      IGINT       ActivePage;                            /* Currently displayed page */
      ImageType   ImageType;                             /* Monochrome Raster, Color Raster, Vector, Text */
      OrientType  Orientation;                           /* Orientation (rotation)*/
      IGINT       Resolution;                            /* DPI */
      IGINT       Reserved;                              /* Four byte field for correct compiler structure padding in 16 and 32 bit environments */
      IGINT       NumberOfFiles;                         /* Number of entries in the filepath array of files */
      ImageInfo   ImageInfo[1];                          /* For all images (first entry and subsequent overlays): full path and worldscale */
} NotifyInquireDocument, *pNotifyInquireDocument;


/* THIS IS THE INITIAL COMMAND ISSUED TO START THE CALLBACK.....
void doInquireDocument(BOOL bUseCommandString)
{
       char ExecutionString[MAX_STRING];

   if(!IsServerUp()){
      PrintLine("There is no connection to Myriad.");
      return;
   }

   if(bUseCommandString){
      PrintLine("Sending Inquire Document string to Myriad...");

      // Setup the execution string
     strcpy(ExecutionString, "inquire_document()");

     if(ProcessExecutionString(ExecutionString)){
         PrintLine("--> Inquire Document succeeded.");
     }else{
         PrintLine("--> Inquire Document failed.");
     }
  }else{
     PrintLine("Sending Inquire Document to Myriad...");

     if(ProcessExecutionCommand(INTG_EXECUTE_INQUIRE_DOCUMENT, NULL)){
        PrintLine("--> Inquire Document succeeded.");
     }else{
        PrintLine("--> Inquire Document failed.");
     }
  }
}


long FAR PASCAL WndProc(HWND hWnd, unsigned iMessage, WORD wParam, LONG lParam)
{
   int ret=0;
   int rc=TRUE;

   switch (iMessage){
      case WM_PAINT:{
         PaintWindow();
     }
     break;

      case IGC_NOTIFY_CALLBACK_MESSAGE:{
        NotifyCallbackHandler((struct NotifyCallbackRecord *)lParam);
     }
     break;

      case WM_COMMAND:{
         switch (wParam){
          case IDM_COMMAND_COMMAND_INQUIRE_DOCUMENT:{
                 doInquireDocument(FALSE);
            }
             break;
        default:{
         return DefWindowProc(hWnd, iMessage, wParam, lParam);
      }
   }

   return(FALSE);
}

// Callback handler for notification messages
void NotifyCallbackHandler(struct NotifyCallbackRecord *pCallbackRecord)
{
   char tempstring[MAX_STRING];
   
   switch(pCallbackRecord->Message){
         case INTG_NOTIFY_DOCUMENT_INFO: {
         HandleInquireDocumentPrint(&pCallbackRecord->Data);
      }
      break;
      default:{
         sprintf(tempstring, ">>> Received unhandled notify message %d", (int)pCallbackRecord->Message);
         PrintLine(tempstring);
      }
      break;
   }
}

void HandleInquireDocumentPrint(void *pData)
{
   pNotifyInquireDocument pRecord;
   char                   tempString[MAX_STRING];
   pImageInfo             ptr;
   int                    i;


   if ((pRecord = pData) != NULL) {
      sprintf(tempString, ">>> Inquire Document Info: ");
      PrintLine(tempString);

      if (pRecord->MarkupFile[0] != '\0') {
         sprintf(tempString, "Markup file: %s", pRecord->MarkupFile);
         PrintLine(tempString);
         if (pRecord->MarkupChanged)
            sprintf(tempString, "Markup file has been changed");
         else
            sprintf(tempString, "Markup file has not been changed");
         PrintLine(tempString);
      }
      else {
         sprintf(tempString, "Markup file: None");
         PrintLine(tempString);
      }

      sprintf(tempString, "Description: %s", pRecord->Description);
      PrintLine(tempString);

      sprintf(tempString, "Current viewed area (clip): %lf, %lf, %lf, %lf", pRecord->Clip[0],
                           pRecord->Clip[1], pRecord->Clip[2], pRecord->Clip[3]);
      PrintLine(tempString);

      sprintf(tempString, "Limits of the document: %lf, %lf, %lf, %lf", pRecord->Limits[0],
                           pRecord->Limits[1], pRecord->Limits[2], pRecord->Limits[3]);
      PrintLine(tempString);

      sprintf(tempString, "Document window size: %ld, %ld, %ld, %ld", pRecord->DocWindowSize[0],
         pRecord->DocWindowSize[1], pRecord->DocWindowSize[2], pRecord->DocWindowSize[3]);
      PrintLine(tempString);

      sprintf(tempString, "Document window position: %ld, %ld, %ld, %ld", pRecord->DocWindowPosition[0],
         pRecord->DocWindowPosition[1], pRecord->DocWindowPosition[2], pRecord->DocWindowPosition[3]);
      PrintLine(tempString);

     strcpy(tempString, "Document window state: ");

     switch(pRecord->DocWindowState.State){
        case WINDOW_MINIMIZED : strcat(tempString, "Minimized");break;
        case WINDOW_MAXIMIZED : strcat(tempString, "Maximized");break;
        case WINDOW_WINDOWED  : strcat(tempString, "Windowed");break;
     }

     PrintLine(tempString);

      sprintf(tempString, "Myriad window size: %ld, %ld, %ld, %ld", pRecord->MyrWindowSize[0],
         pRecord->MyrWindowSize[1], pRecord->MyrWindowSize[2], pRecord->MyrWindowSize[3]);
      PrintLine(tempString);

      sprintf(tempString, "Myriad window position: %ld, %ld, %ld, %ld", pRecord->MyrWindowPosition[0],
         pRecord->MyrWindowPosition[1], pRecord->MyrWindowPosition[2], pRecord->MyrWindowPosition[3]);
      PrintLine(tempString);

     strcpy(tempString, "Myriad window state: ");

     switch(pRecord->MyrWindowState.State){
        case WINDOW_MINIMIZED : strcat(tempString, "Minimized");break;
        case WINDOW_MAXIMIZED : strcat(tempString, "Maximized");break;
        case WINDOW_WINDOWED  : strcat(tempString, "Windowed");break;
     }

     PrintLine(tempString);

      sprintf(tempString, "Number of pages: %ld", pRecord->NumberOfPages);
      PrintLine(tempString);

      sprintf(tempString, "Active page: %ld", pRecord->ActivePage);
      PrintLine(tempString);

      sprintf(tempString, "Image type: ");
      switch (pRecord->ImageType.Type) {
         case MONOCHROME_RASTER: strcat(tempString, "Monochrome Raster"); break;
         case COLOR_RASTER: strcat(tempString, "Color Raster"); break;
      case VECTOR: strcat(tempString, "Vector"); break;
         case TEXT: strcat(tempString, "Text"); break;
      }
      PrintLine(tempString);

      sprintf(tempString, "Orientation: ");
      switch (pRecord->Orientation.Type) {
      case DEGREES_0: strcat(tempString, "0 Degrees"); break;
         case DEGREES_90: strcat(tempString, "90 Degrees"); break;
      case DEGREES_180: strcat(tempString, "180 Degrees"); break;
         case DEGREES_270: strcat(tempString, "270 Degrees"); break;
      }
      PrintLine(tempString);

      sprintf(tempString, "Resolution: %ld", pRecord->Resolution);
      PrintLine(tempString);

      sprintf(tempString, "Number of files: %ld", pRecord->NumberOfFiles);
      PrintLine(tempString);

      sprintf(tempString, "Files:");
      PrintLine(tempString);

      ptr = pRecord->ImageInfo;
   
      for (i = 0; i < pRecord->NumberOfFiles; i++) {
         sprintf(tempString, "Name:%s  World Scale:%lf", ptr->Filename, ptr->WorldScale);
         PrintLine(tempString);
         ptr++;
      }
         
   } else {
      PrintLine(">>> Notify Inquire Document (Invalid data packet)");
   }
}



Now, Here's my VB vesrsion:
Public Declare Function StartAndInitServer Lib ".\myrcmd32.dll" (ByVal ServerName As String) As Boolean
Public Declare Function IsServerUp Lib "myrcmd32.dll" () As Boolean
Public Declare Function ProcessExecutionString Lib "myrcmd32.dll" (ByVal pString As String) As Boolean
Public Declare Function SetNotifyWindow Lib "myrcmd32.dll" (ByVal hWnd As Long) As Boolean

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Three versions for testing
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Long, ByVal cbCopy As Long)
Private Declare Sub CopyMemory3 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Double, ByVal cbCopy As Long)

Public Const MYRIAD_EXECUTABLE_NAME As String = "myriad32.exe"
Private Const GWL_WNDPROC = (-4)
Private Const WM_USER As Long = &H400
Private Const IGC_NOTIFY_CALLBACK_MESSAGE  As Long = (WM_USER + 10000)

Private Enum isostrings
    EXECUTE_ISO_FONT
    EXECUTE_ISO_CLEAR_ALL
    EXECUTE_ISO_RESTORE_DEFAULTS
    EXECUTE_ISO_TOPLEFT
    EXECUTE_ISO_TOPCENTER
    EXECUTE_ISO_TOPRIGHT
    EXECUTE_ISO_BOTTOMLEFT
    EXECUTE_ISO_BOTTOMCENTER
    EXECUTE_ISO_BOTTOMRIGHT
    EXECUTE_ISO_LEFTTOP
    EXECUTE_ISO_LEFTCENTER
    EXECUTE_ISO_LEFTBOTTOM
    EXECUTE_ISO_RIGHTTOP
    EXECUTE_ISO_RIGHTCENTER
    EXECUTE_ISO_RIGHTBOTTOM
    EXECUTE_ISO_WATERMARK
End Enum

Private Enum DataStatusType
    INTG_STATUS_COMPLETE_DATA
    INTG_STATUS_PARTIAL_DATA
    INTG_STATUS_NO_DATA
    INTG_STATUS_REPLY_REQUESTED
End Enum

Private Enum ExecutePrintScaleTypes
    EXECUTE_PRINT_SCALE_PAGE
    EXECUTE_PRINT_SCALE_TO_SCALE
End Enum

Private Enum ExecutePrintRangeTypes
    EXECUTE_PRINT_RANGE_ALL
    EXECUTE_PRINT_RANGE_PAGES
    EXECUTE_PRINT_RANGE_CURRENT
End Enum

Private Enum ExecutePrintOrientTypes
    EXECUTE_PRINT_ORIENT_PORTRAIT
    EXECUTE_PRINT_ORIENT_LANDSCAPE
End Enum

Private Enum ExecutePrintPrintWhatTypes
    EXECUTE_PRINT_DOCUMENT
    EXECUTE_PRINT_NOTES
End Enum

' These are the notification message types which identify the type of
' data packet being received by the integrating application
Private Enum NotifyMessageType
    INTG_NOTIFY_NONE
    INTG_NOTIFY_EXECUTION_RETURN
    INTG_NOTIFY_MOUSEMOVE
    INTG_NOTIFY_LBUTTONDOWN
    INTG_NOTIFY_LBUTTONUP
    INTG_NOTIFY_LBUTTONDBLCLICK
    INTG_NOTIFY_EXIT
    INTG_LOAD_FILEBEGIN
    INTG_LOAD_BLOCKBEGIN
    INTG_LOAD_ATTRIBUTE
    INTG_LOAD_BLOCKEND
    INTG_LOAD_FILEEND
    INTG_DISPLAY_FILEBEGIN
    INTG_DISPLAY_BLOCKBEGIN
    INTG_DISPLAY_ATTRIBUTE
    INTG_DISPLAY_BLOCKEND
    INTG_DISPLAY_FILEEND
    INTG_LAUNCH_ATTRIBBLOCK
    INTG_NOTIFY_SET_RETURN_DATA
    INTG_NOTIFY_FILE_LOADED
    INTG_NOTIFY_VIEWPORT_CLOSE
    INTG_NOTIFY_OPEN_MARKUP
    INTG_NOTIFY_SAVE_MARKUP
    INTG_NOTIFY_MARKUP_SAVED
    INTG_NOTIFY_CLOSE_MARKUP
    INTG_NOTIFY_IMAGE_CHANGE
    INTG_NOTIFY_GET_LAYER_INFO
    INTG_NOTIFY_GET_ISO_STRING
    INTG_NOTIFY_DATABASE_LOOKUP
    INTG_NOTIFY_PRINT
    INTG_NOTIFY_PRINT_COMPLETE
    INTG_NOTIFY_UD_MENU
    INTG_NOTIFY_OPEN_MARKUP_REQUEST
    INTG_NOTIFY_DOCUMENT_INFO
    INTG_NOTIFY_SYSTEM_INFO
    INTG_NOTIFY_SAVEAS_MARKUP_REQUEST
    INTG_NOTIFY_GET_AUTHORS
    INTG_NOTIFY_CHANGEMARK_VIEWED
    INTG_NOTIFY_GET_CHANGEMARKS
    INTG_NOTIFY_NEW_MARKUP
    INTG_NOTIFY_RUN_SILENT_MSG
    INTG_NOTIFY_ISO_DISPLAY
    INTG_NOTIFY_ISO_EDIT
    INTG_NOTIFY_DATABASE_ISO_LOOKUP
    INTG_NOTIFY_INTEGRATION_ENABLED
    INTG_NOTIFY_3D_MODEL_LOADED
    INTG_NOTIFY_3D_COMPONENT_SELECTION_CHANGED
    INTG_NOTIFY_3D_COMPONENT_LIST_ENABLED
    INTG_NOTIFY_PRINT_PREVIEW_COMPLETE
    INTG_NOTIFY_OPEN_MVS_REQUEST
    INTG_NOTIFY_SAVEAS_MVS_REQUEST
    INTG_NOTIFY_MVS_SAVED
    INTG_NOTIFY_CLOSE_MVS
    INTG_NOTIFY_HTML_EXPORT_FILE_WRITTEN
    INTG_NOTIFY_MVS_VIEW_CREATED
    INTG_NOTIFY_VIEW_SET_FILE_LOADED
    INTG_NOTIFY_VIEW_SET_NEEDS_SAVING
End Enum

Private Enum ExecutePrintPaperSizeTypes
    EXECUTE_PRINT_SIZE_DEFAULT
    EXECUTE_PRINT_SIZE_LETTER
    EXECUTE_PRINT_SIZE_LEGAL
    EXECUTE_PRINT_SIZE_A4
    EXECUTE_PRINT_SIZE_CSHEET
    EXECUTE_PRINT_SIZE_DSHEET
    EXECUTE_PRINT_SIZE_ESHEET
    EXECUTE_PRINT_SIZE_LETTERSMALL
    EXECUTE_PRINT_SIZE_TABLOID
    EXECUTE_PRINT_SIZE_LEDGER
    EXECUTE_PRINT_SIZE_STATEMENT
    EXECUTE_PRINT_SIZE_EXECUTIVE
    EXECUTE_PRINT_SIZE_A3
    EXECUTE_PRINT_SIZE_A4SMALL
    EXECUTE_PRINT_SIZE_A5
    EXECUTE_PRINT_SIZE_B4
    EXECUTE_PRINT_SIZE_B5
    EXECUTE_PRINT_SIZE_FOLIO
    EXECUTE_PRINT_SIZE_QUARTO
    EXECUTE_PRINT_SIZE_10X14
    EXECUTE_PRINT_SIZE_11X17
    EXECUTE_PRINT_SIZE_NOTE
    EXECUTE_PRINT_SIZE_ENV9
    EXECUTE_PRINT_SIZE_ENV10
    EXECUTE_PRINT_SIZE_ENV11
    EXECUTE_PRINT_SIZE_ENV12
    EXECUTE_PRINT_SIZE_ENV14
    EXECUTE_PRINT_SIZE_ENVDL
    EXECUTE_PRINT_SIZE_ENVC5
    EXECUTE_PRINT_SIZE_ENVC3
    EXECUTE_PRINT_SIZE_ENVC4
    EXECUTE_PRINT_SIZE_ENVC6
    EXECUTE_PRINT_SIZE_ENVC65
    EXECUTE_PRINT_SIZE_ENVB4
    EXECUTE_PRINT_SIZE_ENVB5
    EXECUTE_PRINT_SIZE_ENVB6
    EXECUTE_PRINT_SIZE_ENVITALY
    EXECUTE_PRINT_SIZE_ENVMONARCH
    EXECUTE_PRINT_SIZE_ENVPERSONAL
    EXECUTE_PRINT_SIZE_FANFOLD_US
    EXECUTE_PRINT_SIZE_FANFOLD_STDGERMAN
    EXECUTE_PRINT_SIZE_FANFOLD_LGLGERMAN
    EXECUTE_PRINT_SIZE_ISOB4
    EXECUTE_PRINT_SIZE_JAPANESE_POSTCARD
    EXECUTE_PRINT_SIZE_9X11
    EXECUTE_PRINT_SIZE_10X11
    EXECUTE_PRINT_SIZE_15X11
    EXECUTE_PRINT_SIZE_ENV_INVITE
    EXECUTE_PRINT_SIZE_LETTER_EXTRA
    EXECUTE_PRINT_SIZE_LEGAL_EXTRA
    EXECUTE_PRINT_SIZE_TABLOID_EXTRA
    EXECUTE_PRINT_SIZE_A4_EXTRA
    EXECUTE_PRINT_SIZE_LETTER_TRANSVERSE
    EXECUTE_PRINT_SIZE_A3_TRANSVERSE
    EXECUTE_PRINT_SIZE_A3_EXTRA_TRANSVERSE
    EXECUTE_PRINT_SIZE_A4_TRANSVERSE
    EXECUTE_PRINT_SIZE_LETTER_EXTRA_TRANSVERSE
    EXECUTE_PRINT_SIZE_A5_TRANSVERSE
    EXECUTE_PRINT_SIZE_B5_TRANSVERSE
    EXECUTE_PRINT_SIZE_A_PLUS
    EXECUTE_PRINT_SIZE_B_PLUS
    EXECUTE_PRINT_SIZE_LETTER_PLUS
    EXECUTE_PRINT_SIZE_A4_PLUS
    EXECUTE_PRINT_SIZE_A3_EXTRA
    EXECUTE_PRINT_SIZE_A5_EXTRA
    EXECUTE_PRINT_SIZE_B5_EXTRA
    EXECUTE_PRINT_SIZE_A2
    EXECUTE_PRINT_SIZE_USER
End Enum

Private Type ImageInfo
    WorldScale As Double
    Filename(255) As Byte
End Type

Private Type WindowState
    State As Long
End Type

Private Type ImageType
  Type As Long
End Type

Private Type OrientType
  Type As Long
End Type

Private Type NotifyCallbackRecord
    Message As Long 'The message ID for the notification
    DataStatus As Long 'The status of the data attached to the notification
    Data As Long  'The address of the data attached to the notification
End Type

Private Type NotifyInquireDocument
    clip(3) As Double 'current viewed area
    limits(3) As Double  'limits of the document
    markupfile(255) As Byte 'The editable markup file if one opened, NULL if no markup opened
    markupchanged As Long 'If the current editable markup has been changed
    description(255) As Byte 'extracted from the folder file
    docwindowsize(3) As Long 'The RECT associated with the image window
    docwindowposition(3) As Long 'The device location of the window image (RECT)
    docwindowstate As WindowState 'The state of the image window
    myrwindowsize(3) As Long 'the RECT associated with Myriad's main window
    myrwindowpos(3) As Long 'The device location of Myriad's main window
    myrwindowstate As WindowState 'The state of Myriad's main window
    numberofpages As Long 'The number of pages in the image
    activepage As Long 'Currently displayed page
    ImageType As ImageType  'Monochrome Raster, Color Raster, Vector, Text
    orientation As OrientType  'Orientation (rotation)
    resolution As Long 'DPI
    reserved As Long 'Four byte field for correct compiler structure padding in 16 and 32 bit environments
    numberoffiles As Long 'Number of entries in the filepath array of files
    ImageInfo(0) As ImageInfo 'For all images (first entry and subsequent overlays): full path and worldscale
End Type

Dim PrevProc As Long, pCallBackRecord As NotifyCallbackRecord
'---------------- my test vars ------------------------------
'Private Const OFFSET_4 = 4294967296#
'Private Const MAXINT_4 = 2147483647
'Private Const OFFSET_2 = 65536
'Private Const MAXINT_2 = 32767
Dim str As String
Dim i As Integer
Dim b As Byte
Dim newDub As Double
'------------------------------------------------------------

Public Sub HookForm(f As Form)
PrevProc = SetWindowLong(f.hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub UnHookForm(f As Form)
SetWindowLong f.hWnd, GWL_WNDPROC, PrevProc
End Sub

Private Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
WindowProc = CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
If uMsg = IGC_NOTIFY_CALLBACK_MESSAGE Then
'------------- my debug code ------------------------------------
            For i = 0 To LenB(pCallBackRecord) - 1
                CopyMemory b, ByVal lParam + i, 1
                str = str & b & ","
            Next i


            str = Left$(str, Len(str) - 1)
            bites = Split(str, ",")
            h0 = Hex(bites(11))
            h1 = Hex(bites(10))
            h2 = Hex(bites(9))
            h3 = Hex(bites(8))
            On Error Resume Next
            newDub = CDbl("&H" & h0 & h1 & h2 & h3)
            If newDub < 0 Then
            'remove the most significant bit (negative flag)
            newDub = newDub And Not &H80000000
            'now subtract the smallest allowable long number value
            'to add in the long number negative flag (&h80000000) as a positive value
            newDub = newDub - CDbl("&h80000000")
            End If

            Open App.Path & "\dumplog.txt" For Output As #1
            Write #1, str, newDub
            Close #1
'----------------------------------------------------------------
    CopyMemory pCallBackRecord, ByVal lParam, ByVal LenB(pCallBackRecord)
    MsgBox "procdata: " & pCallBackRecord.Message & "," & pCallBackRecord.DataStatus & "," & pCallBackRecord.Data
    processData
End If
End Function

Private Sub processData()
Dim pRecord As NotifyInquireDocument
Dim myStr As String, longval As Long

myStr = String(256, 0)
Select Case pCallBackRecord.Message
    Case INTG_NOTIFY_DOCUMENT_INFO
        If pCallBackRecord.DataStatus = INTG_STATUS_COMPLETE_DATA Then
            MsgBox "copying data value: " & pCallBackRecord.Data & " len prec:" & LenB(pRecord)

            'unsuccessful attempt at converting the address...
'            If pCallBackRecord.Data < 0 Then
'               longval = CLng(&H7FFFFFFF And pCallBackRecord.Data) - 1
'            Else
'               longval = pCallBackRecord.Data
'            End If
'            MsgBox "longval:" & longval
'            CopyMemory3 pRecord, longval, ByVal LenB(pRecord)
'MsgBox "copymem newdub:" & newDub
'CopyMemory3 pRecord, newDub, ByVal LenB(pRecord)
            CopyMemory2 pRecord, pCallBackRecord.Data, ByVal LenB(pRecord)
            With Form1.Text2
            .Text = ""
            .Text = "clip: " & pRecord.clip(0) & " , " & pRecord.clip(1) & " , " & pRecord.clip(2) & " , " & pRecord.clip(3) & vbCrLf
            .Text = .Text & "limits: " & pRecord.limits(0) & " , " & pRecord.limits(1) & " , " & pRecord.limits(2) & " , " & pRecord.limits(3) & vbCrLf
            CopyMemory3 myStr, pRecord.markupfile(0), ByVal LenB(myStr)
            .Text = .Text & "markupfile: " & myStr & vbCrLf
            .Text = .Text & "markupchanged: " & pRecord.markupchanged & vbCrLf
            CopyMemory3 myStr, pRecord.description(0), ByVal LenB(myStr)
            .Text = .Text & "desc: " & myStr & vbCrLf
            .Text = .Text & "docwindowsize: " & pRecord.docwindowsize(0) & " , " & pRecord.docwindowsize(1) & " , " & pRecord.docwindowsize(2) & " , " & pRecord.docwindowsize(3) & vbCrLf
            .Text = .Text & "docwindowposition: " & pRecord.docwindowposition(0) & " , " & pRecord.docwindowposition(1) & " , " & pRecord.docwindowposition(2) & " , " & pRecord.docwindowposition(3) & vbCrLf
            .Text = .Text & "docwindowstate: " & pRecord.docwindowstate.State & vbCrLf
            .Text = .Text & "myrwinpos: " & pRecord.myrwindowpos(0) & " , " & pRecord.myrwindowpos(1) & " , " & pRecord.myrwindowpos(2) & " , " & pRecord.myrwindowpos(3) & vbCrLf
            .Text = .Text & "winstate: " & pRecord.myrwindowstate.State & vbCrLf
            .Text = .Text & "numpgs: " & pRecord.numberofpages & vbCrLf
            .Text = .Text & "activepage: " & pRecord.activepage & vbCrLf
            .Text = .Text & "ImageType: " & pRecord.ImageType.Type & vbCrLf
            .Text = .Text & "orientation: " & pRecord.orientation.Type & vbCrLf
            .Text = .Text & "resolution: " & pRecord.resolution & vbCrLf
            .Text = .Text & "reserved: " & pRecord.reserved & vbCrLf
            .Text = .Text & "numberoffiles: " & pRecord.numberoffiles & vbCrLf
            CopyMemory3 myStr, pRecord.ImageInfo(0).Filename(0), ByVal LenB(myStr)
            .Text = .Text & "ImageInfoFilename: " & myStr & vbCrLf
            .Text = .Text & "ImageInfoWorldScale: " & pRecord.ImageInfo(0).WorldScale
            End With
         End If
'    Case INTG_NOTIFY_SYSTEM_INFO
End Select
End Sub



0
 
LVL 7

Expert Comment

by:webJose
ID: 8036416
Private Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Long, ByVal cbCopy As Long)

 CopyMemory2 pRecord, pCallBackRecord.Data, ByVal LenB(pRecord)

This is wrong.  The declaration must be:

Private Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)

or the call must be:

 CopyMemory2 pRecord, ByVal pCallBackRecord.Data, ByVal LenB(pRecord)

Either way you correct the code, you should get the correct results.  Right now you are not passing the pointer to the data, you are passing the pointer to the pointer to the data.

As a note, when you write

Filename(255) As Byte

Are you wanting 256 bytes?  Because that is what it is.  If you wanted 255 bytes, then you must decrease that by one.  I never use that kind of notation because it is confusing.  If I wanted 256 bytes, I would use:

Filename(0 to 255) as Byte

I always explicitly state the lower and upper bounds.

Anyway, hope this will solve your problem.
0
 
LVL 1

Author Comment

by:wehoit
ID: 8036955
Either change you suggested causes the app to crash.

Private Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)

or the call must be:

CopyMemory2 pRecord, ByVal pCallBackRecord.Data, ByVal LenB(pRecord)

I've been working with this for over 2 months.
I've tried about 50 variations of Copymem...

The first CopyMem call returns pCallBackRecord.Data (sometimes) as a negative number.
The address value coming from the callback is a full 8 byte unsigned long (I believe) which VB cannot process directly. That's why there is a failed attempt in the code at converting the address to something VB can handle.

This is why I keep saying that the problem is deeper than just the declaration.

If you were willing to download my test app you'd see.

As for the Filename(255) As Byte declaration, yes, I want 256 bytes. I do not find this confusing as I've used VB for several years.
0
 
LVL 7

Expert Comment

by:webJose
ID: 8037114
Are you saying you are using 64-bit pointers?  Because I have ZERO experience with them.  I have only worked with 32-bit systems.

Now, ignoring the previous paragraph for a moment, I must say that my correction is a must because it is the proper use.  Remember that no matter how you alter the declaration of CopyMemory, the function will always interpret the first parameter as a 32-bit pointer, and the second one as a 32-bit pointer.  So, if you have the address in a long variable, you must pass it by value, not by reference.  The correction must be done.  The program crashing is elsewhere.  And to try to find it, set a break point in the corrected line, then press F8.  The program should not crash there, but if it does, then the pointer cannot be read.  If this is data allocated in another process, then that process must be allocating it in global memory, otherwise the Windows protected mode will raise an Access violation error at the moment you try to use CopyMemory.

If I am correct and you can safely pass the corrected line, then I can examine the code further and see if there is a problem downstream.
0
 
LVL 7

Expert Comment

by:webJose
ID: 8037168
Yes, I bet it does not crash in the corrected line.  I just saw this:

CopyMemory3 myStr, pRecord.markupfile(0), ByVal LenB(myStr)

Way wrong.  I am assuming pRecord.markupfile contains the actual array of chars you want to pass to the string variable.  If so, you must use this:

mystr =space(256)
copymemory byval mystr, pRecord.markupfile(0), 256

See?  It seems that after all the problem IS proper usage of CopyMemory.
0
 
LVL 1

Author Comment

by:wehoit
ID: 8037212
It is not the usage of CopyMem that is the problem.

You can test this by commenting out all the .Text lines which are used to show the results.
That eliminates any possbility of error as you've shown.
It still crashes.

As I've said before, I've been through this for 2 months and tried dozens of variations.


You can "bet" all you want, but unless you actually download the code, I cannot continue this.

0
 
LVL 7

Expert Comment

by:webJose
ID: 8037266
Ok, since you think I'm an ignorant, research elsewhere.  Like I said, your copymemory usage is wrong, especially with strings.  VB strings are more complex than C strings.  I won't explain as you don't believe me, but try this quick example in a new project:

option explicit

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSrc As Any, ByVal ByteLen As Long)

private sub form_load()

dim strData as string
dim arrbData(1 to 5) as byte

    arrbdata(1) = asc("H")
    arrbdata(2) = asc("e")
    arrbdata(3) = asc("l")
    arrbdata(4) = asc("l")
    arrbdata(5) = asc("o")
    strdata = space(5)
    copymemory byval strdata, arrbdata(1), 5
    msgbox strdata
end sub


And then try it your way and tell me if you still think you know what you are doing.
0
 
LVL 1

Author Comment

by:wehoit
ID: 8037369
I don't think you're ignorant.

I think you're proposing solutions based on only a superficial knowledge of the specific problem.

In this code, you can declare and use CopyMem any way you like. But, it only does one of two things:
1) Crash
2) Return useless info

I described this in my initial post.
0
 
LVL 7

Expert Comment

by:webJose
ID: 8037402
Try the example, then try it your way, please.  Then let me know if you still think your copymemory usage is a problem.  This would be your way:

Private Sub Form_Load()

Dim strData As String
Dim arrbData(1 To 5) As Byte

    arrbData(1) = Asc("H")
    arrbData(2) = Asc("e")
    arrbData(3) = Asc("l")
    arrbData(4) = Asc("l")
    arrbData(5) = Asc("o")
    CopyMemory strData, arrbData(1), 5
    MsgBox strData
End Sub
0
 
LVL 7

Expert Comment

by:webJose
ID: 8037440
And by the way, I am not trying to resolve all problems at once.  I am (or was) going step by step since your code has many errors.  I was just trying to correct the CopyMemory usage, and if that wasn't enough then go deeper into other aspects.  But believe me when I say that your CopyMemory usage is WRONG.  Ask anybody.
0
 
LVL 1

Author Comment

by:wehoit
ID: 8037556
Like I posted before, I tried changing the delcaration and it crashed at the CopyMem statement.

Then, I tried changing the call, and it still crashed.

So, right or wrong, it's still crashing.

If you don't believe me, download the code and try it yourself.

Why do you keep going back to the CopyMem statement if I say it crashes? Doesn't that say to you that the problem is, perhaps, with the address VALUE that that comes back from the first copymem?
You can declare Copymem the right way (and, by the way, if you notice, there are other versions of copymem declared correctly in the code!) but if you send it an invalid VALUE it can crash.
This is what is happening.

If you had downloaded the code so you could see the VALUEs coming back from pCallBackRecord.Data you'd understand.
0
 
LVL 1

Author Comment

by:wehoit
ID: 8065009
Anyone else want to give this a try?
0
 
LVL 1

Author Comment

by:wehoit
ID: 8112107
Ok - I've upped the point value to 120 now.

Anyone willing to work with this?????
0
 

Expert Comment

by:SpideyMod
ID: 8131909
A request for a refund has been made.  Experts you have 72 hours to object.  Thanks

SpideyMod
Community Support Moderator @Experts Exchange
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8153811
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question