|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
je voudrais juste savoir si :
HSE_URL_MAPEX_INFO humi; if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, static_variable_buf, &variable_len, (LPDWORD) &humi)) { ..... la varialble (LPDWORD) &humi à t'elle été initialisé/creé ou pas ? comme serverSupportFunction c'est un fonction qui s'execute dans mon code delphi j'ai un bug bizarre et je sais pas d'ou il viens ! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
loki a écrit :
> je voudrais juste savoir si : > > HSE_URL_MAPEX_INFO humi; > > if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, static_variable_buf, &variable_len, (LPDWORD) &humi)) { ..... > > la varialble (LPDWORD) &humi à t'elle été initialisé/creé ou pas ? Crée, oui. Initialisée, si c'est du c, non. La variable, c'est "humi". &humi, c'est l'adresse de la variable. La fonction attend donc un pointeur sur la variable (car peut être qu'elle va modifier cette variable). Il faut avoir la doc de la fonction pointée par ServerSupportFunction pour savoir si la variable dont l'adresse est transmise doit être initialisée ou pas. Jean |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
merci pour la réponse !
disons que J'ai besoin de comprendre/traduire le code c ci-dessous : HSE_URL_MAPEX_INFO humi; typedef struct _HSE_URL_MAPEX_INFO{ CHAR lpszPath[MAX_PATH]; DWORD dwFlags; DWORD cchMatchingPath; DWORD cchMatchingURL; DWORD dwReserved1; DWORD dwReserved2; } HSE_URL_MAPEX_INFO, *LPHSE_URL_MAPEX_INFO; static_variable_buf[0] = '/'; static_variable_buf[1] = 0; variable_len = 2; if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, static_variable_buf, &variable_len, (LPDWORD) &humi)) { /* Remove trailing \ */ if (humi.lpszPath[variable_len-2] == '\\') { humi.lpszPath[variable_len-2] = 0; } dans mon delphi j'ai : function ServerSupportFunction(hConn: HCONN; HSERRequest: DWORD; Buffer: Pointer; Size: LPDWORD; DataType: LPDWORD ): BOOL; stdcall; begin // la je veux retourner humi.lpszPath avec une valeur a moi .... mais je comprend pas j'ai un bug ici à chaque fois ! end; Begin .... MyEcb.ServerSupportFunction := ServerSupportFunction; .... end; Mille fois merci par avance stephane "Jean Lacoste" <lacoste@alussinan.org> wrote in message news:fn9kff$kau$1@sd-6498.dedibox.fr... > loki a écrit : >> je voudrais juste savoir si : >> >> HSE_URL_MAPEX_INFO humi; >> >> if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, static_variable_buf, &variable_len, (LPDWORD) &humi)) { ..... >> >> la varialble (LPDWORD) &humi à t'elle été initialisé/creé ou pas ? > > Crée, oui. Initialisée, si c'est du c, non. > La variable, c'est "humi". &humi, c'est l'adresse de la variable. La > fonction attend donc un pointeur sur la variable (car peut être qu'elle > va modifier cette variable). > > Il faut avoir la doc de la fonction pointée par ServerSupportFunction > pour savoir si la variable dont l'adresse est transmise doit être > initialisée ou pas. > > Jean |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
loki a écrit :
.... > dans mon delphi j'ai : > > function ServerSupportFunction(hConn: HCONN; HSERRequest: DWORD; Buffer: Pointer; Size: LPDWORD; DataType: LPDWORD ): BOOL; stdcall; > begin > // la je veux retourner humi.lpszPath avec une valeur a moi .... mais je comprend pas j'ai un bug ici à chaque fois ! Tu dois caster DataType en pointeur sur un record pascal qui correspond au type transmis pour pouvoir l'utiliser dans la fonction. Ne faisant plus de delphi, j'ai totalement oublié la syntaxe ridicule que propose ce langage dès qu'il est question de pointeur. Note que quand tu dis : // la je veux retourner humi.lpszPath avec une valeur a moi c'est faux. Tu veux modifier un membre de la structure originale dont la référence a été transmise à ta fonction. Jean |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
je fais comme cela :
{-------------------------} HSE_URL_MAPEX_INFO = record lpszPath : array[0..MAX_PATH - 1] of CHAR; dwFlags : DWORD; cchMatchingPath : DWORD; cchMatchingURL : DWORD; dwReserved1 : DWORD; dwReserved2 : DWORD; end; LPHSE_URL_MAPEX_INFO = ^HSE_URL_MAPEX_INFO; THSE_URL_MAPEX_INFO = HSE_URL_MAPEX_INFO; function ALPhpRunnerECBServerSupportFunction(hConn: HCONN; HSERRequest: DWORD; Buffer: Pointer; Size: LPDWORD; DataType: LPDWORD ): BOOL; stdcall; Var MapInfo : THSE_URL_MAPEX_INFO; begin MapInfo := THSE_URL_MAPEX_INFO(Pointer(DataType)^); TmpPath := AlCopyStr(String(Pchar(Buffer)),1,size^); If tmpPath = '' then result := false else begin Result := true; TmpPath := ExpandFilename('c:\inetpub\wwwroot\arkadia\'+ TmpPath); ALMove(TmpPath[1], MapInfo.lpszPath[0], Length(TmpPath)); MapInfo.cchMatchingPath := Length(TmpPath); end; end; le probleme c que dans le prog C j'ai n'importe quoi comme variable en resultat de cela : document_root=`ã stephane "Jean Lacoste" <lacoste@alussinan.org> wrote in message news:fnabtm$19d$1@sd-6498.dedibox.fr... > loki a écrit : > ... >> dans mon delphi j'ai : >> >> function ServerSupportFunction(hConn: HCONN; HSERRequest: DWORD; Buffer: Pointer; Size: LPDWORD; DataType: LPDWORD ): BOOL; stdcall; >> begin >> // la je veux retourner humi.lpszPath avec une valeur a moi .... mais je comprend pas j'ai un bug ici à chaque fois ! > > Tu dois caster DataType en pointeur sur un record pascal qui correspond > au type transmis pour pouvoir l'utiliser dans la fonction. Ne faisant > plus de delphi, j'ai totalement oublié la syntaxe ridicule que propose > ce langage dès qu'il est question de pointeur. > > Note que quand tu dis : > // la je veux retourner humi.lpszPath avec une valeur a moi > c'est faux. Tu veux modifier un membre de la structure originale dont la > référence a été transmise à ta fonction. > > Jean |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
loki a écrit :
> je fais comme cela : > > {-------------------------} > HSE_URL_MAPEX_INFO = record > lpszPath : array[0..MAX_PATH - 1] of CHAR; > dwFlags : DWORD; > cchMatchingPath : DWORD; > cchMatchingURL : DWORD; > dwReserved1 : DWORD; > dwReserved2 : DWORD; > end; > LPHSE_URL_MAPEX_INFO = ^HSE_URL_MAPEX_INFO; > THSE_URL_MAPEX_INFO = HSE_URL_MAPEX_INFO; > > > function ALPhpRunnerECBServerSupportFunction(hConn: HCONN; HSERRequest: DWORD; Buffer: Pointer; Size: LPDWORD; DataType: LPDWORD ): BOOL; stdcall; > Var MapInfo : THSE_URL_MAPEX_INFO; > begin > > MapInfo := THSE_URL_MAPEX_INFO(Pointer(DataType)^); > TmpPath := AlCopyStr(String(Pchar(Buffer)),1,size^); > If tmpPath = '' then result := false > else begin > Result := true; > TmpPath := ExpandFilename('c:\inetpub\wwwroot\arkadia\'+ TmpPath); > ALMove(TmpPath[1], MapInfo.lpszPath[0], Length(TmpPath)); > MapInfo.cchMatchingPath := Length(TmpPath); > end; > > end; > > > le probleme c que dans le prog C j'ai n'importe quoi comme variable en resultat de cela : DataType contient l'adresse. Il "suffit" de le caster en pointeur sur la structure. Tu dois ensuite manipuler le record par ce pointeur (MapInfo n'est pas un record mais un pointeur sur un record). Var MapInfo : LPHSE_URL_MAPEX_INFO; begin ... MapInfo := LPHSE_URL_MAPEX_INFO(DataType); ... mais je sais pas si la syntaxe du cast est correcte. Jean |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
La franchement j'ai cherché comme un malade ! pointeur pas initialisé avant, transtypage incorrecte, manager de memoire planté, etc..... mais c'etait vraiment VICIEUX le truc !
la declaration c du truc : typedef struct _HSE_URL_MAPEX_INFO HSE_URL_MAPEX_INFO { CHAR lpszPath[MAX_PATH]; DWORD dwFlags; DWORD cchMatchingPath; DWORD cchMatchingURL; DWORD dwReserved1; DWORD dwReserved2; } HSE_URL_MAPEX_INFO, * LPHSE_URL_MAPEX_INFO;la traduction pascal: HSE_URL_MAPEX_INFO = record lpszPath : array[0..MAX_PATH - 1] of CHAR; dwFlags : DWORD; cchMatchingPath : DWORD; cchMatchingURL : DWORD; dwReserved1 : DWORD; dwReserved2 : DWORD; end; LPHSE_URL_MAPEX_INFO = ^HSE_URL_MAPEX_INFO; THSE_URL_MAPEX_INFO = HSE_URL_MAPEX_INFO;jusque la tout va bien ! dans mon code je recois un DataType: LPDWORD en guise de pointeur et moi je fait : MapInfo := THSE_URL_MAPEX_INFO(Pointer(DataType)^); voire ensuite MapInfo := LPHSE_URL_MAPEX_INFO(pointer(DataType)^); (vous l'avez compris quelle con j'ai oublié d'enlever le ^ !) mais moi je savais pas que meme si l'adress est completement pipo, aucune erreur ne va etre lever ! et la ensuite je fait mumuse avec ma variable dans mon code delphi MapInfo.lpszPath := 'VA CHIEZ'; dans le code C++ MapInfo.lpszPath = '$^ù...' grosso modo c'est moi qui comence a faire kaka la !! bon je regarde de droite a gauche (je passe le details) et je me dit : si ca ce trouve j'ai mal traduit la variable CHAR lpszPath[MAX_PATH]; je vais le traduire en lpszPath : PCHAR; et je recommence dans mon code delphi MapInfo.lpszPath := 'Va faire caca stp!'; dans le code C++ MapInfo.lpszPath = 'Va faire caca stp!' et purré de purré je me dis mais quand meme c'est gros le truc la ! parcque j'ai beau etre idiot mais CHAR lpszPath[MAX_PATH]; ca veux dire ce que ca veux dire, alors pourquoi ca marche avec Pchar ... je cherche ... je cherche puis la tu me donne la reponse ! au lieu de faire comme un ane MapInfo := THSE_URL_MAPEX_INFO(DataType^); je fait MapInfo := THSE_URL_MAPEX_INFO(DataType); et la nickel ca marche ! d'ailleur pourquoi ca marchais avec le declaration en PCHAR d'ailleurs !!!! phuuuuuu ral le bol ! tout ce temps perdu a cause d'une simple ^ !! stephane "Jean Lacoste" <lacoste@alussinan.org> wrote in message news:fnahf2$3t3$1@sd-6498.dedibox.fr... > loki a écrit : >> je fais comme cela : >> >> {-------------------------} >> HSE_URL_MAPEX_INFO = record >> lpszPath : array[0..MAX_PATH - 1] of CHAR; >> dwFlags : DWORD; >> cchMatchingPath : DWORD; >> cchMatchingURL : DWORD; >> dwReserved1 : DWORD; >> dwReserved2 : DWORD; >> end; >> LPHSE_URL_MAPEX_INFO = ^HSE_URL_MAPEX_INFO; >> THSE_URL_MAPEX_INFO = HSE_URL_MAPEX_INFO; >> >> >> function ALPhpRunnerECBServerSupportFunction(hConn: HCONN; HSERRequest: DWORD; Buffer: Pointer; Size: LPDWORD; DataType: LPDWORD ): BOOL; stdcall; >> Var MapInfo : THSE_URL_MAPEX_INFO; >> begin >> >> MapInfo := THSE_URL_MAPEX_INFO(Pointer(DataType)^); >> TmpPath := AlCopyStr(String(Pchar(Buffer)),1,size^); >> If tmpPath = '' then result := false >> else begin >> Result := true; >> TmpPath := ExpandFilename('c:\inetpub\wwwroot\arkadia\'+ TmpPath); >> ALMove(TmpPath[1], MapInfo.lpszPath[0], Length(TmpPath)); >> MapInfo.cchMatchingPath := Length(TmpPath); >> end; >> >> end; >> >> >> le probleme c que dans le prog C j'ai n'importe quoi comme variable en resultat de cela : > > DataType contient l'adresse. Il "suffit" de le caster en pointeur sur la > structure. Tu dois ensuite manipuler le record par ce pointeur (MapInfo > n'est pas un record mais un pointeur sur un record). > > Var > MapInfo : LPHSE_URL_MAPEX_INFO; > begin > ... > MapInfo := LPHSE_URL_MAPEX_INFO(DataType); > ... > > mais je sais pas si la syntaxe du cast est correcte. > > Jean |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
> MapInfo.lpszPath := 'VA CHIEZ';
> MapInfo.lpszPath := 'Va faire caca stp!'; Es-tu vraiment obligé d'écrire en des termes aussi vulgaires ? -- francois.piette@overbyte.be Auteur du freeware ICS - Internet Component Suite Auteur du middleware multi-tiers MidWare web: http://www.overbyte.be blog: http://francois-piette.blogspot.com |
|
![]() |
| Outils de la discussion | |
|
|