title: How to set a PreSharedKey in a RasEntry on Windows CE / Compact Framework?
body: <p>Since I really don't get any progress in the last hours I need to consult you for a problem which I don't get solved.
  We have a Win CE 5.0 application, written C#/Compact Frmaework 2.0 that uses RASDial to Dial into a VPN. Currently it uses PPTP but I have to change it to L2TP with a Pre Shard Key. But to be honest I have no experience in C++ and I really understand only half of the code or to be more clear I don't understand the RAS Api and Documentation in the MSDN.
  I understand how to create this L2PT RAS Entry and how to Dial it but in no way I understand where and how to set the Pre Shared Key! 
  I found a peace of code that seems to do the same things our code does in priciple but on the Website/Board I found it the Author says this is with pre shared key but to be honest, I don't get where the key is.</p>
  
  <p>(...) </p>
  
  <pre><code>// Device configuration for L2TP VPN 
  if (bIsL2TP) { 
      DWORD cbKey = 0; 
      if (g_sharedKey) { 
          cbKey = (wcslen(g_sharedKey))*sizeof(WCHAR); 
      } 
      pL2TPConfigData = (PL2TP_CONFIG_DATA)new BYTE 
  [sizeof(L2TP_CONFIG_DATA)+ cbKey]; 
  
  
      ZeroMemory(pL2TPConfigData, sizeof(L2TP_CONFIG_DATA)+ cbKey); 
      pL2TPConfigData-&gt;dwVersion = 1; 
      pL2TPConfigData-&gt;dwAuthType = L2TP_IPSEC_AUTH_PRESHAREDKEY; 
      pL2TPConfigData-&gt;dwFlags = 0; 
      pL2TPConfigData-&gt;cbKey = cbKey; 
      pL2TPConfigData-&gt;dwOffsetKey = sizeof(L2TP_CONFIG_DATA); 
      pL2TPConfigData-&gt;cMyCerts = 0; 
      pL2TPConfigData-&gt;cRootCerts = 0; 
      pL2TPConfigData-&gt;dwOffsetCertHashes = sizeof(L2TP_CONFIG_DATA); 
      if (g_sharedKey) { 
          memcpy((PBYTE)pL2TPConfigData+pL2TPConfigData-&gt;dwOffsetKey, 
  g_sharedKey, cbKey); 
      } 
      pConfigData = (PBYTE)pL2TPConfigData; 
      cbConfigData = sizeof(L2TP_CONFIG_DATA) + cbKey; 
  } 
  
  
  (...) 
  
  
  // Create a new phone-book entry. 
  res = ::RasSetEntryProperties(NULL, g_entryName, &amp;rasEntry, sizeof 
  (rasEntry), pConfigData, cbConfigData); 
  if (res != 0) { 
      wprintf(L"Cannot create or update the phone book entry (error# %u). 
  Aborting.", res); 
      goto exit; 
  } 
  </code></pre>
  
  <p>In the code the Length (cbKey) of the key is determined but can someone explain to me where the actual key is in the code? Or can someone provide me an explaination on how to set a Pre Shared Key in RASEntry for L2TP?</p>
  
  <p>Thank you so much</p>
  
  <p>twickl</p>