Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Access dll over Christof Lange's struct class
Message
 
 
À
27/07/2001 08:05:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00536282
Message ID:
00536288
Vues:
8
Hi!

Find CLSHEAP.PRG that allows you to create a pointer to memory and operate them, as well as use them as integer values to pass to API functions that require pointers. Specially useful for pointers inside of structures - just integer in the structure definition replaced by pointer created using CLSHEAP.PRG. Works using pure API functions, so you can strip out them and do all this by self using CLSHEAP.PRG as a sample only.

If you cannot find it, Email me so I will send it to you.

>Hello,
>
>
>i want to access a self written plain C dll from within FVP with help from
>christof lange's struct class
>
>the problem is i had to pass a pointer to a structure containing
>serveral other pointers and int values ..
>
>the passing works just fine .. but when i want to read out the data
>back with the SetString procedure
>the values get not updatet properly ..
>
>here are some snipets of the source code:
>
>dll -> struct definition in header file:
>
>struct hlserver {
> int id;
> char *host_name;
> char *address;
> unsigned int ipaddr;
> unsigned short port;
> char *server_name;
> char *map_name;
> char *gamedir;
> char *game;
> int num_players;
> int max_players;
> int protocol_version;
> char *sv_type;
> char *sv_os;
>};
>
>dll -> function that is called from vfp:
>
>char* HLRequestDetail ( struct hlserver *server)
>{
>
> SOCKET HLSock;
> struct sockaddr_in HLAddr;
> int HLpktlen, HLData;
> char *HLok;
> long pkt_data[PACKET_LEN/sizeof(long)];
> char *pkt= (char*)&pkt_data[0];
> server->ipaddr = inet_addr(server->address);
>
> HLSock = socket(AF_INET,SOCK_DGRAM,0);
> HLAddr.sin_family = AF_INET;
> HLAddr.sin_port = htons(server->port);
> HLAddr.sin_addr.s_addr = server->ipaddr;
> sendto(HLSock,hl_details,12,0,(struct sockaddr *)
> &HLAddr,sizeof(HLAddr));
> HLpktlen = sizeof(HLAddr);
> HLData = recvfrom(HLSock,pkt,sizeof(pkt_data)
> ,0,(struct sockaddr *)&HLAddr,&HLpktlen);
>
>
>/* normaly now i would read out the data out of the recieved packet, but for testing purposes i generated the following lines of code to simulate some return values */
>
> server->server_name= "HeinzTest";
> server->map_name= "de_test";
> server->num_players= 5;
> server->max_players= 12;
> server->protocol_version= 47;
> return;
>....
>
>
>here the code from vfp:
>
>&& Creat object of my subclass hlserverinfo from class struct
>lnServerHandle = CreateObject ("hlserverinfo")
>
>&& Start DLL Winsock ( WSAStartup with version checking , must be at least 1.1 )
>lnStartNet = HLStartNet()
>if lnStartNet = 1
> return
>endif
>
>lcBuffer = lnServerHandle.GetString( ) && Initiate Structure from Object Strings
>
>lnecho = HLRequestDetail( @lcBuffer ) && Call DLL with Structure Reference
>
>lnServerHandle.SetString( m.lcBuffer ) && Read out of Structure to object properties
>
>&& Read values in form
>this.parent.txtTest.value = alltrim(lnServerHandle.sAddress)
>
>and so on ...
>
>declared the dll in fvp as followed:
>
>DECLARE STRING HLRequestDetail in hlspydll STRING @
>
>would be really nice if someone could give me tips/suggestions are even better a solution to my problem .. cause without this function my entire programm would be useless
>
>THX beforehand
>
>Christian Ehlscheid
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform